Examples of WeatherReport


Examples of org.hivedb.util.database.test.WeatherReport

  public void testAllShardsQuery() {
    final DataAccessObject<WeatherReport, Integer> dao = (DataAccessObject<WeatherReport, Integer>) getDao(getGeneratedClass());
    final int INSTANCES = 20;
    Collection<WeatherReport> reports = Generate.create(new Generator<WeatherReport>() {
      public WeatherReport generate() {
        WeatherReport report = new GenerateInstance<WeatherReport>(WeatherReport.class).generate();
        GeneratedInstanceInterceptor.setProperty(report, "latitude", 1d);
        GeneratedInstanceInterceptor.setProperty(report, "regionCode", 1); // used to verify node spread
        dao.save(report);
        return report;
      }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  public void testIsTransient() throws Exception{
    EntityHiveConfig config = getEntityHiveConfig();
    Hive hive = getHive();
    HiveInterceptorDecorator interceptor = new HiveInterceptorDecorator(config, hive);

    WeatherReport report = generateInstance();
    Continent asia = new AsiaticContinent();

    assertNotNull(config.getEntityConfig(asia.getClass()));

    assertTrue(interceptor.isTransient(report));
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  public void testOnSaveInsert() throws Exception {
    EntityHiveConfig config = getEntityHiveConfig();
    Hive hive = getHive();
    HiveInterceptorDecorator interceptor = new HiveInterceptorDecorator(config, hive);

    WeatherReport report = generateInstance();
    Continent asia = new AsiaticContinent();
    hive.directory().insertPrimaryIndexKey(asia.getName());
    hive.directory().insertPrimaryIndexKey(report.getContinent());
    interceptor.postFlush(Arrays.asList(new Object[]{report,asia}).iterator());

    assertTrue(hive.directory().doesResourceIdExist("WeatherReport", report.getReportId()));
    assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));

    assertTrue(hive.directory().doesPrimaryIndexKeyExist(asia.getName()));
    assertTrue(hive.directory().doesSecondaryIndexKeyExist("Continent", "population", asia.getPopulation(), asia.getName()));

  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

    Hive hive = getHive();
    ConfigurationReader reader = new ConfigurationReader(Continent.class, WeatherReport.class);
    EntityHiveConfig config = reader.getHiveConfiguration();
    HiveInterceptorDecorator interceptor = new HiveInterceptorDecorator(config, hive);

    WeatherReport report = generateInstance();
    hive.directory().insertPrimaryIndexKey(report.getContinent());
    hive.updateHiveStatus(Lockable.Status.readOnly);
    try {
      interceptor.postFlush(Arrays.asList(new Object[]{report}).iterator());
      fail("No exception thrown");
    } catch(CallbackException e ) {
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

    EntityHiveConfig config = getEntityHiveConfig();
    Hive hive = getHive();

    HiveInterceptorDecorator interceptor = new HiveInterceptorDecorator(config, hive);

    WeatherReport report = generateInstance();
    hive.directory().insertPrimaryIndexKey(report.getContinent());
    interceptor.postFlush(Arrays.asList(new WeatherReport[]{report}).iterator());

    assertTrue(hive.directory().doesPrimaryIndexKeyExist(report.getContinent()));
    assertTrue(hive.directory().doesResourceIdExist("WeatherReport", report.getReportId()));
    assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));

    hive.updateHiveStatus(Lockable.Status.readOnly);
    try {
      interceptor.onDelete(report, null, null, null, null);
      fail("No exception thrown");
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  // Test for HiveIndexer.insert(final EntityIndexConfiguration config, final Object entity)
  @Test
  public void insertTest() throws Exception {
    Hive hive = getHive();
    HiveIndexer indexer = new HiveIndexer(hive);
    WeatherReport report = generateInstance();
    indexer.insert(getWeatherReportConfig(report), report);
    assertTrue(hive.directory().doesResourceIdExist("WeatherReport", report.getReportId()));
    assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));
    for (WeatherEvent weatherEvent : report.getWeatherEvents())
      assertTrue(hive.directory().doesSecondaryIndexKeyExist("WeatherReport", "weatherEventEventId", weatherEvent.getEventId(), report.getReportId()));
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

    Hive hive = getHive();
    ConfigurationReader reader = new ConfigurationReader(Continent.class, WeatherReport.class);
    EntityHiveConfig config = reader.getHiveConfiguration();
    HiveInterceptorDecorator interceptor = new HiveInterceptorDecorator(config, hive);

    WeatherReport report = generateInstance();
    Continent asia = new AsiaticContinent();
    hive.directory().insertPrimaryIndexKey(report.getContinent());
    hive.directory().insertPrimaryIndexKey(asia.getName());
    interceptor.postFlush(Arrays.asList(new Object[]{report,asia}).iterator());

    assertTrue(hive.directory().doesPrimaryIndexKeyExist(report.getContinent()));
    assertTrue(hive.directory().doesResourceIdExist("WeatherReport", report.getReportId()));
    assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));

    assertTrue(hive.directory().doesPrimaryIndexKeyExist(asia.getName()));
    assertTrue(hive.directory().doesSecondaryIndexKeyExist("Continent", "population", asia.getPopulation(), asia.getName()));

    interceptor.onDelete(report, null, null, null, null);
    interceptor.onDelete(asia, null, null, null, null);

    assertFalse(hive.directory().doesResourceIdExist("WeatherReport", report.getReportId()));
    // Referenced entity does not get deleted
    assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));

    assertFalse(hive.directory().doesPrimaryIndexKeyExist(asia.getName()));
    assertFalse(hive.directory().doesSecondaryIndexKeyExist("Continent", "population", asia.getPopulation(), asia.getName()));

  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  // Test for HiveIndexer.update(EntityIndexConfiguration config, Object entity)
  @Test
  public void updateTest() throws Exception {
    Hive hive = getHive();
    HiveIndexer indexer = new HiveIndexer(hive);
    WeatherReport report = generateInstance();
    Integer oldTemp = report.getTemperature();
    indexer.insert(getWeatherReportConfig(report), report);
    assertWeatherReportResourceIdsOfPrimaryIndexKey("WeatherReport", report);
    assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));
    GeneratedInstanceInterceptor.setProperty(report, "temperature", 32);
    indexer.update(getWeatherReportConfig(report), report);
    assertEquals(report.getContinent(), hive.directory().getPrimaryIndexKeyOfResourceId("Temperature", 32));
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  public void testOnSaveUpdate() throws Exception {
    Hive hive = getHive();
    EntityHiveConfig config = getEntityHiveConfig();
    HiveInterceptorDecorator interceptor = new HiveInterceptorDecorator(config, hive);

    WeatherReport report = generateInstance();
    hive.directory().insertPrimaryIndexKey(report.getContinent());
    interceptor.postFlush(Arrays.asList(new WeatherReport[]{report}).iterator());

    assertTrue(hive.directory().doesPrimaryIndexKeyExist(report.getContinent()));
    assertTrue(hive.directory().doesResourceIdExist("WeatherReport", report.getReportId()));
    assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));

    int oldTemperature = report.getTemperature();
    GeneratedInstanceInterceptor.setProperty(report, "temperature", 72);
    assertFalse(oldTemperature == 72);
    interceptor.postFlush(Arrays.asList(new WeatherReport[]{report}).iterator());
    assertTrue(hive.directory().doesResourceIdExist("Temperature", 72));
  }
View Full Code Here

Examples of org.hivedb.util.database.test.WeatherReport

  @Test
  public void changePartitionKeyTest() throws Exception {
    Hive hive = getHive();
    HiveIndexer indexer = new HiveIndexer(hive);
    WeatherReport report = generateInstance();
    GeneratedInstanceInterceptor.setProperty(report, "continent", "Asia");
    Integer oldTemp = report.getTemperature();
    indexer.insert(getWeatherReportConfig(report), report);
    assertWeatherReportResourceIdsOfPrimaryIndexKey("WeatherReport", report);
    assertTrue(hive.directory().doesResourceIdExist("Temperature", report.getTemperature()));
    assertEquals("Asia", hive.directory().getPrimaryIndexKeyOfResourceId("WeatherReport", report.getReportId()));

    GeneratedInstanceInterceptor.setProperty(report, "continent", "Europe");
    indexer.update(getWeatherReportConfig(report), report);
    GeneratedInstanceInterceptor.setProperty(report, "temperature", 32);
    indexer.update(getWeatherReportConfig(report), report);

    assertEquals("Europe", hive.directory().getPrimaryIndexKeyOfResourceId("WeatherReport", report.getReportId()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.