@Test
 public void testDeviceList() {
   assumeNotNull(relayId);
   assumeNotNull(thermostatId);
   NADeviceListResponse deviceList = api.devicelist("app_thermostat", relayId, false);
   NADevice relay = deviceList.getBody().getDevices().get(0);
   assertEquals(relay.getId(), relayId);
   assertTrue(relay.getModules().contains(new String(thermostatId)));
 }
 @Test
 public void testGetMeasure() {
   assumeNotNull(relayId);
   assumeNotNull(thermostatId);
   CSVParams params = new CSVParams("Temperature", "Sp_Temperature", "BoilerOn", "BoilerOff");
   assertEquals(
       api.getmeasure(relayId, "max", params, thermostatId, null, null, null, null, null)
           .getBody()
           .get(0)
           .getValue()
           .get(0)
           .size(),
       4);
 }
 @Test
 public void testGetRate() throws Exception {
   Assume.assumeNotNull(
       RateService.getInstance()
           .getRate(
               Currency.getInstance(Locale.GERMANY).getCurrencyCode(),
               new GregorianCalendar(2010, 6, 1)));
 }
 /** Test to show assumptions using "org.junit.Assume.assumeNotNull()" method */
 @Test
 public void showAssumptionsUsingAssumeNotNull() {
   // Execute this test only if the assumption below is verified, if the
   // assumption is not verified the test being marked as passing,
   // regardless of what the code below the assumption may assert (the test code below assumption
   // is not executed)
   Assume.assumeNotNull(this.bean);
   System.out.println(
       "showAssumptionsUsingAssumeNotNull() : Assumption verified then test code is executed !");
 }
 @Test
 public void assumeNotNullIncludesParameterList() {
   try {
     Object[] objects = {1, 2, null};
     assumeNotNull(objects);
   } catch (AssumptionViolatedException e) {
     assertThat(e.getMessage(), containsString("1, 2, null"));
   } catch (Exception e) {
     fail("Should have thrown AssumptionViolatedException");
   }
 }
  @Test
  public void testSetpoint() {
    assumeNotNull(relayId);
    assumeNotNull(thermostatId);
    Float setpointTemp = Float.valueOf(20);

    NAThermStateBody thermState = api.getthermstate(relayId, thermostatId).getBody();
    NASetpoint setpoint = thermState.getSetpointOrder();
    if (setpoint == null) {
      setpoint = thermState.getSetpoint();
    }

    // If already in manual mode, ensure that the temp will be changed
    if (setpoint.getSetpointMode() == "manual") {
      setpointTemp = setpoint.getSetpointTemp() + Float.valueOf(0.5f);
    }

    // Send order
    api.setthermpoint(
        relayId,
        thermostatId,
        "manual",
        (int) (System.currentTimeMillis() / 1000 + 30),
        setpointTemp);

    // Verify order
    thermState = api.getthermstate(relayId, thermostatId).getBody();
    if (thermState.getSetpointOrder() != null) {
      assertEquals(thermState.getSetpointOrder().getSetpointTemp(), setpointTemp);
    } else {
      assertEquals(thermState.getSetpoint().getSetpointTemp(), setpointTemp);
    }

    // Rollback previous mode
    api.setthermpoint(
        relayId,
        thermostatId,
        setpoint.getSetpointMode(),
        setpoint.getSetpointEndtime(),
        setpoint.getSetpointTemp());
  }
 @Theory
 public void idempotence(
     final @TestURL.TestURLs(dataset = TestURL.DATASETS.WHATWG) TestURL testURL)
     throws GalimatiasParseException {
   assumeNotNull(testURL.parsedURL);
   final URLCanonicalizer canon = new DecodeUnreservedCanonicalizer();
   final URL roundOne = canon.canonicalize(testURL.parsedURL);
   final URL roundTwo = canon.canonicalize(roundOne);
   assertThat(roundOne).isEqualTo(roundTwo);
   final URL reparse = URL.parse(roundTwo.toString());
   assertThat(reparse).isEqualTo(roundTwo);
 }
  @Test
  public void testParseTemplateConfigFile() throws Exception {
    SubutaiTemplateMetadata metadata;
    try (InputStream is = ClassLoader.getSystemResourceAsStream("config")) {
      Assume.assumeNotNull(is);
      metadata = parser.parseTemplateConfigFile(is);
    }

    Assert.assertEquals("hadoop", metadata.getName());
    Assert.assertEquals("2.1.2", metadata.getVersion());
    Assert.assertEquals(Architecture.AMD64, metadata.getArchitecture());
    Assert.assertFalse(metadata.getExtra().isEmpty());
  }
Esempio n. 9
0
  @Test(expected = EntityNotFoundException.class)
  public void testDelete() {
    Product p = new Product("foo", "bar");
    Product pp = dao.save(p);

    assumeNotNull(pp.getKey());

    String id = KeyFactory.keyToString(pp.getKey());
    Product fp = dao.find(id);

    dao.delete(fp);

    dao.find(id); // throws EntityNotFoundException
  }
 @Test
 public void testGetAllPartitionKeys() throws Exception {
   CloudTableClient tableClient = createTableClient();
   assumeNotNull(tableClient);
   t = createTable(tableClient);
   insertRow(t, "p1", "r1");
   insertRow(t, "p1", "r2");
   insertRow(t, "p2", "r1");
   insertRow(t, "p3", "r1");
   List<String> partitionKeys = DefaultTablePartitioner.getAllPartitionKeys(t);
   assertEquals(3, partitionKeys.size());
   assertEquals("p1", partitionKeys.get(0));
   assertEquals("p2", partitionKeys.get(1));
   assertEquals("p3", partitionKeys.get(2));
 }
Esempio n. 11
0
  public static void setUpTest(Module module) {
    Connection connection = null;
    try {

      DataSource ds = module.findService(DataSource.class).get();
      connection = ds.getConnection();
      Assume.assumeNotNull(connection);

    } catch (Throwable t) {

      t.printStackTrace();
      Assume.assumeNoException(t);

    } finally {

      SQLUtil.closeQuietly(connection);
    }
  }
Esempio n. 12
0
  // helper method to get coverage of the unused constructor
  @Test
  public void testPrivateConstructor() throws Exception {
    // skip test if we do not have a graphical Display
    Assume.assumeNotNull(Display.getCurrent());

    PrivateConstructorCoverage.executePrivateConstructor(Constants.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.Colors.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.Cursors.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.Modules.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.Images.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.InternalMessages.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.Html.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.Misc.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.Procedures.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.ConfigurationXml.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.CmdArguments.class);
    PrivateConstructorCoverage.executePrivateConstructor(Constants.REST.class);
    PrivateConstructorCoverage.executePrivateConstructor(RESTConstants.class);
  }
Esempio n. 13
0
  @Test
  public void testInstantiate() {
    TestHelpers.assumeCanUseDisplay();
    Display display = new Display();

    // skip test if we do not have a graphical Display
    Assume.assumeNotNull(Display.getCurrent());

    LOGGER.info("Constants: " + Constants.Colors.WHITE);
    LOGGER.info("Cursors: " + Constants.Cursors.ARROW);
    LOGGER.info("Modules: " + Constants.Modules.B2B_BACKEND);
    LOGGER.info("Images: " + Constants.Images.FANCY_MENU_BUTTON_BG);
    LOGGER.info("InternalMessages: " + Constants.InternalMessages.MENU_ACTION_WAS_NULL);
    LOGGER.info("HTML: " + Constants.Html.BEGIN_BOLD);
    LOGGER.info("Misc: " + Constants.Misc.CMD_PARAM_ADK_AGENT_LIB);
    LOGGER.info("Procedures: " + Constants.Procedures.ANT_ID);
    LOGGER.info("ConfigurationXML: " + Constants.ConfigurationXml.ATTRIBUTE_ENABLED);
    LOGGER.info("CmdArguments: " + Constants.CmdArguments.NO_AUTOSTART);
    LOGGER.info("REST: " + Constants.REST.PING);
    LOGGER.info("REST: " + RESTConstants.AGENT_FOUND);

    display.dispose();
  }
Esempio n. 14
0
 @Test
 public void assumeNotNullPasses() {
   Object[] objects = {1, 2};
   assumeNotNull(objects);
   assertCompletesNormally();
 }
Esempio n. 15
0
 @Test(expected = AssumptionViolatedException.class)
 public void assumeNotNullThrowsException() {
   Object[] objects = {1, 2, null};
   assumeNotNull(objects);
 }
  @Test
  public void test() {

    /** German */
    /* Baseline: BagOfWords, BagOfLemmas */
    File configFile =
        new File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base_DE.xml");
    //		0.61125

    /* GermaNet: GermaNet without POS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_GN_DE.xml");
    //		0.51125

    /* GermaNetPos: GermaNet with POS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_GNPos_DE.xml");
    //		0.51125

    /* Baseline + GermaNet */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GN_DE.xml");
    //		0.61875

    /* Baseline + GermaNetPos */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GNPos_DE.xml");
    //		0.615

    /* DistSim: distributional similarity */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_DS_DE.xml");
    //		0.51125

    /* Baseline + DistSim */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+DS_DE.xml");
    //		0.6125

    /* DBPos: DerivBase with POS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_DBPos_DE.xml");
    //		0.51125

    /* Baseline + DBPos */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+DBPos_DE.xml");
    //		0.61375

    /* Baseline + GermaNet + DistSim */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GN+DS_DE.xml");
    //		0.62

    /* Baseline + GermaNetPos + DistSim */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GNPos+DS_DE.xml");
    //		0.61375

    /* Baseline + DistSim + DBPos */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+DS+DBPos_DE.xml");
    //		0.60875

    /* Baseline + GermaNetPos + DistSim + DBPos */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GNPos+DS+DBPos_DE.xml");
    //		0.61625

    /* TP: dependency triples without POS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_TP_DE.xml");
    //		0.58625

    /* TPPos: dependency triples with POS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_TPPos_DE.xml");
    //		0.5875

    /* Baseline + TP */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TP_DE.xml");
    //		0.62375

    /* Baseline + TPPos */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TPPos_DE.xml");
    //		0.63125

    /* TS: tree skeleton scoring */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_TS_DE.xml");
    //		0.58

    /* Baseline + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TS_DE.xml");
    //		0.625

    /* Baseline + TP + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TP+TS_DE.xml");
    //		0.62875

    /* Baseline + TPPos + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TPPos+TS_DE.xml");
    //		0.63375

    /* Baseline + TP + TPPos + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TP+TPPos+TS_DE.xml");
    //		0.63375

    /* Baseline + DS + TPPos + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+DS+TPPos+TS_DE.xml");
    //		0.62375

    /* Baseline + GNPos + DS + TPPos + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GNPos+DS+TPPos+TS_DE.xml");
    //		0.63

    /* Baseline + GNPos + DS + DBPos + TPPos + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GNPos+DS+DBPos+TPPos+TS_DE.xml");
    //		0.63125

    /* TransDm */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_TransDm_DE.xml");
    //		0.51125

    /* TransDm with POS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_TransDmPos_DE.xml");
    //		0.51125

    /* Baseline + TransDm */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TransDm_DE.xml");
    //		0.61625

    /* Baseline + TransDm with POS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TransDmPos_DE.xml");
    //		0.62

    /* Baseline + TransDm with POS + TP + TPPOS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TransDmPos+TP+TPPos_DE.xml");
    //		0.6275

    /* Baseline + TransDm with POS + TP + TPPOS + TS  */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TransDmPos+TP+TPPos+TS_DE.xml");
    //		0.635

    /* Baseline + GermaNet + DerivBase + TransDm with POS + TP + TPPOS + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GNPos+DBPos+TransDmPos+TP+TPPos+TS_DE.xml");
    //		0.635

    /* Baseline + GermaNet + TransDm with POS + TP + TPPOS + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GNPos+TransDmPos+TP+TPPos+TS_DE.xml");
    //		0.63625

    /* Baseline + DerivBase + TransDm with POS + TP + TPPOS + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+DBPos+TransDmPos+TP+TPPos+TS_DE.xml");
    //		0.63

    /* Baseline + GermaNet + DistSim + DerivBase + TransDm with POS + TP + TPPOS + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+GNPos+DS+DBPos+TransDmPos+TP+TPPos+TS_DE.xml");
    //		0.6325

    /* Baseline + DistSim + TP + TPPOS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+DS+TP+TPPos_DE.xml");
    //		0.62625

    /* Baseline + DistSim + TP + TPPOS + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+DS+TP+TPPos+TS_DE.xml");
    //		0.6275

    /** English */
    /* Baseline */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base_EN.xml");
    //		0.625

    /* WN: WordNet */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_WN_EN.xml");
    //		0.5125

    /* Baseline + WN */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+WN_EN.xml");
    //		0.63 false false false
    //		0.6325 true false false (default)
    //		0.62375 false true true
    //		0.62625 true true true

    /* VO: VerbOcean */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_VO_EN.xml");
    //		0.5125 true (default)
    //		0.5075 false

    /* Baseline + VO */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+VO_EN.xml");
    //		0.6225 true (default)
    //		0.6225 false

    /* Baseline + WN + VO */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+WN+VO_EN.xml");
    //		0.62375

    /* TP: dependency triples without POS */

    /* TPPos: dependency triples with POS */

    /* Baseline + TP */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TP_EN.xml");
    //		0.63125

    /* Baseline + TPPos */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TPPos_EN.xml");
    //		0.63

    /* TS: tree skeleton scoring */

    /* Baseline + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TS_EN.xml");
    //		0.63625

    /* Baseline + TP + TS */

    /* Baseline + TPPos + TS */

    /* Baseline + TP + TPPos + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+TP+TPPos+TS_EN.xml");
    //		0.64375

    /* Baseline + WN + VO + TP + TPPos + TS */
    //		File configFile = new
    // File("./src/main/resources/configuration-file/MaxEntClassificationEDA_Base+WN+VO+TP+TPPos+TS_EN.xml");
    //		0.645

    Assume.assumeTrue(configFile.exists());
    CommonConfig config = null;
    try {
      // read in the configuration from the file
      config = new ImplCommonConfig(configFile);
    } catch (ConfigurationException e) {
      logger.warning(e.getMessage());
    }
    Assume.assumeNotNull(config);

    // Gil: testLAP_DE() is a very very long test. (More than build process itself)
    // German RTE tests
    //		testLAP_DE();
    //		testParser_DE();
    //		testTraining(config);
    //		testTesting_SingleTH(config);
    //		testTesting_MultiTH(config);
    //		testTesting_MultiTH_AND_Output(config);

    // Rui: testLAP_EN(), testTraining_EN(), and testTesting_MultiTH_EN() also take long time
    /* English RTE tests
    testLAP_EN();
    testParser_EN("poly");
    testTraining(config);
    testTesting_SingleTH(config);
    testTesting_MultiTH(config);
    testTesting_MultiTH_AND_Output(config);
     */
  }
 private void setUpContext(String tokenName) {
   String accessToken = System.getProperty(tokenName);
   Assume.assumeNotNull(accessToken);
   context.setAccessToken(new DefaultOAuth2AccessToken(accessToken));
 }
Esempio n. 18
0
 @Before
 public void setUp() {
   this.cloudinary = new Cloudinary();
   assumeNotNull(cloudinary.getStringConfig("api_secret"));
   this.api = cloudinary.api();
 }
  @Test
  public void testSchedule() {
    assumeNotNull(relayId);
    assumeNotNull(thermostatId);
    NAThermStateBody thermState = api.getthermstate(relayId, thermostatId).getBody();

    if (thermState.getThermProgram().getName().equals(TEST_PROGRAM_NAME)
        || (thermState.getThermProgramOrder() != null
            && thermState.getThermProgramOrder().getName().equals(TEST_PROGRAM_NAME))) {
      throw new RuntimeException(
          "The test program should not be the one in use at the beginning of the test !");
    }

    // Get program
    NAThermProgram program = thermState.getThermProgramOrder();
    if (program == null) {
      program = thermState.getThermProgram();
    }
    String previousProgramId = program.getProgramId();

    // Do we need to create a test program ?
    // Note : if you want to test the program creation, you need to delete the test program manually
    // on Netatmo'site since it cannot be done by API.
    NAThermProgram testProgram = getExitingTestProgram(thermState);
    if (testProgram == null) {
      testProgram = program;
      testProgram.setProgramId(null);
      testProgram.setName(TEST_PROGRAM_NAME);
      NANewScheduleResponse newscheduleResponse =
          api.createnewschedule(relayId, thermostatId, testProgram);
      assertEquals(newscheduleResponse.getStatus(), "ok");
      testProgram.setProgramId(newscheduleResponse.getBody().getScheduleId());
    }

    // Switch to test schedule
    NAOkResponse naOkResponse =
        api.switchschedule(relayId, thermostatId, testProgram.getProgramId());
    assertEquals(naOkResponse.getStatus(), "ok");

    // Modify schedule
    Float nightTempBefore = null;
    for (NAZone zone : testProgram.getZones()) {
      if (zone.getType() == 1) {
        nightTempBefore = zone.getTemp();
        zone.setTemp(nightTempBefore + Float.valueOf(0.5f));
        break;
      }
    }

    if (nightTempBefore == null) {
      throw new RuntimeException(
          "The current program doesn't have a night zone. This is unexpected by this test !");
    }
    naOkResponse = api.syncschedule(relayId, thermostatId, testProgram);
    assertEquals(naOkResponse.getStatus(), "ok");

    // Verify the change of temperature
    thermState = api.getthermstate(relayId, thermostatId).getBody();
    testProgram = thermState.getThermProgramOrder();
    if (testProgram == null) {
      testProgram = thermState.getThermProgram();
    }

    for (NAZone zone : testProgram.getZones()) {
      if (zone.getType() == 1) {
        assertEquals(nightTempBefore + Float.valueOf(0.5f), zone.getTemp(), 0.0001);
        zone.setTemp(nightTempBefore);
        break;
      }
    }

    // Rollback changes
    api.syncschedule(relayId, thermostatId, testProgram);
    api.switchschedule(relayId, thermostatId, previousProgramId);
  }
 @BeforeClass
 public static void setUpClass() {
   Assume.assumeNotNull(System.getenv("JENKINS_HOME"));
 }