Package org.hivedb.util.database.test

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


  // Test for HiveIndexer.exists(EntityIndexConfiguration config, Object entity)
  @Test
  public void existsTest() throws Exception {
    Hive hive = getHive();
    HiveIndexer indexer = new HiveIndexer(hive);
    WeatherReport report = generateInstance();
    assertFalse(indexer.exists(getWeatherReportConfig(report), report));
    indexer.insert(getWeatherReportConfig(report), report);
    assertTrue(indexer.exists(getWeatherReportConfig(report), report));
  }
View Full Code Here


public class GeneratedClassTest {
 
  @Test
  public void testGetClass() throws Exception {
    WeatherReport instance = new GenerateInstance<WeatherReport>(WeatherReport.class).generate();
    instance.getClass().newInstance();
  }
View Full Code Here

  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

  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

    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(Status.readOnly);
    try {
      interceptor.postFlush(Arrays.asList(new Object[]{report}).iterator());
      fail("No exception thrown");
    } catch (CallbackException e) {
View Full Code Here

    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(Status.readOnly);
    try {
      interceptor.onDelete(report, null, null, null, null);
      fail("No exception thrown");
View Full Code Here

    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

  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

  @Test
  public void testSelectNode() throws Exception {
    ConfigurationReader reader = new ConfigurationReader(Continent.class, WeatherReport.class);
    Hive hive = getHive();
    HiveShardSelector selector = new HiveShardSelector(reader.getHiveConfiguration(), hive);
    WeatherReport report = WeatherReportImpl.generate();

    ShardId id = selector.selectShardIdForNewObject(report);
    Assert.assertNotNull(id);

    Collection<Integer> nodeIds = Transform.map(new Unary<Node, Integer>() {
View Full Code Here

  }

  @Test
  public void configureResourceTest() throws Exception {
    EntityConfig config = new ConfigurationReader().configure(WeatherReport.class);
    WeatherReport report = generateInstance();
    assertEquals(WeatherReport.CONTINENT, config.getPrimaryIndexKeyPropertyName());
    assertEquals(WeatherReport.CONTINENT, config.getPartitionDimensionName());
    assertEquals(report.getContinent(), config.getPrimaryIndexKey(report));
    assertEquals(report.getReportId(), config.getId(report));
    assertEquals("WeatherReport", config.getResourceName());
    assertFalse(config.isPartitioningResource());
    assertEquals(WeatherReport.class, config.getRepresentedInterface());
    assertEquals(Integer.class, config.getIdClass());

    Collection<EntityIndexConfig> indexes = (Collection<EntityIndexConfig>) config.getEntityIndexConfigs();

    EntityIndexConfig temperature = null;
    for (EntityIndexConfig icfg : indexes)
      if ("temperature".equals(icfg.getIndexName())) {
        temperature = icfg;
        break;
      }
    assertNotNull(temperature);
    assertEquals(int.class, temperature.getIndexClass());
    assertEquals(report.getTemperature(), Atom.getFirst(temperature.getIndexValues(report)));

    Filter.grepSingleOrNull(new Predicate<EntityIndexConfig>() {
      public boolean f(EntityIndexConfig entityIndexConfig) {
        return "weatherEventEventId".equals(entityIndexConfig.getIndexName());
      }
View Full Code Here

TOP

Related Classes of org.hivedb.util.database.test.WeatherReport

Copyright © 2018 www.massapicom. 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.