Examples of WeatherReport


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

    int min = 0, max = 0;
    for (int i = 0; i < INSTANCE_COUNT; i++) {
      int temperature = random.nextInt();
      min = Math.min(min, temperature);
      max = Math.max(max, temperature);
      WeatherReport report = new GenerateInstance<WeatherReport>(WeatherReport.class).generate();
      GeneratedInstanceInterceptor.setProperty(report, "temperature", temperature);
      dao.save(report);
      set.add(report);
    }
    final int finalMin = min;
View Full Code Here

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

    final int temperature = random.nextInt();
    final List<String> partitionDimensionKeys = Arrays.asList(new String[]{"Asia", "Andromida"});
    Collection<WeatherReport> reports =
        Generate.create(new Generator<WeatherReport>() {
          public WeatherReport generate() {
            WeatherReport weatherReport = new GenerateInstance<WeatherReport>(WeatherReport.class).generate();
            // Set the same temperature for each partition dimension id. The partition dimension id will be calculated from the report id
            GeneratedInstanceInterceptor.setProperty(weatherReport, "temperature", temperature + weatherReport.getReportId() % 2);
            GeneratedInstanceInterceptor.setProperty(weatherReport, "continent", partitionDimensionKeys.get(weatherReport.getReportId() % 2));
            GeneratedInstanceInterceptor.setProperty(weatherReport, "regionCode", 4);
            return weatherReport;
          }
        }, new NumberIterator(5));
View Full Code Here

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

  @SuppressWarnings("unchecked")
  @Test
  public void testDelete() throws Exception {
    DataAccessObject<WeatherReport, Integer> dao = (DataAccessObject<WeatherReport, Integer>) getDao(getGeneratedClass());
    WeatherReport original = getPersistentInstance(dao);
    dao.delete(original.getReportId());
    assertNull(dao.get(original.getReportId()));
  }
View Full Code Here

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

  @SuppressWarnings("unchecked")
  @Test
  public void testInsert() {
    DataAccessObject<WeatherReport, Integer> dao = (DataAccessObject<WeatherReport, Integer>) getDao(getGeneratedClass());
    WeatherReport report = new GenerateInstance<WeatherReport>(WeatherReport.class).generate();
    dao.save(report);
    WeatherReport savedReport = dao.get(report.getReportId());
    assertNotNull(savedReport);
    assertEquals(report.hashCode(), savedReport.hashCode());
  }
View Full Code Here

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

  @SuppressWarnings("unchecked")
  @Test
  public void testUpdate() throws Exception {
    DataAccessObject<WeatherReport, Integer> dao = (DataAccessObject<WeatherReport, Integer>) getDao(getGeneratedClass());
    WeatherReport original = getPersistentInstance(dao);
    WeatherReport updated = dao.get(original.getReportId());
    GeneratedInstanceInterceptor.setProperty(updated, "latitude", new Double(30));
    GeneratedInstanceInterceptor.setProperty(updated, "longitude", new Double(30));
    /* TODO this fails because we currently don't support one-to-many relationships. We need to reenable the
        deleteOrphanItems in our BaseDataAccessObject to support this
       */
    /*
      // Test collection item updates
      List<WeatherEvent> weatherEvents = new ArrayList<WeatherEvent>(original.getWeatherEvents());
      // Delete the first
      weatherEvents.remove(0);
      // Update the second
      weatherEvents.get(0).setName("foobar");
      // Add a third
      weatherEvents.add(new GenerateInstance<WeatherEvent>(WeatherEvent.class).generate());
      GeneratedInstanceInterceptor.setProperty(updated, "weatherEvents", weatherEvents);
    */
    dao.save(updated);
    //final WeatherReport persisted = dao.get(updated.getReportId());
    assertFalse(updated.getLatitude().equals(original.getLatitude()));
    // Check the updated collection
    // size should be equal
    //assertEquals(original.getWeatherEvents().size(), persisted.getWeatherEvents().size());
    // first item should be removed
    //assertFalse(Filter.grepItemAgainstList(Atom.getFirst(original.getWeatherEvents()), persisted.getWeatherEvents()));
    // should be an updated item named foobar
    /* assertTrue(Filter.grepItemAgainstList("foobar",
          Transform.map(new Unary<WeatherEvent,String>() {
            public String f(WeatherEvent weatherEvent) {
              return weatherEvent.getName();
          }}, persisted.getWeatherEvents()))); */
    // new item should exist
    //assertTrue(Filter.grepItemAgainstList(Atom.getLast(weatherEvents), persisted.getWeatherEvents()));

    String newPrimaryIndexKey = findPrimaryKeyOnDifferentNode(original);
    GeneratedInstanceInterceptor.setProperty(updated, "continent", new Integer(newPrimaryIndexKey).toString());
    Assert.assertEquals(getHive().directory().getNodeIdsOfResourceId("WeatherReport", original.getReportId()).size(), 1);
    dao.save(updated);
    final Collection<Integer> nodeIdsOfResourceId = getHive().directory().getNodeIdsOfResourceId("WeatherReport", updated.getReportId());
    // Make sure the resource is only on 1 hive node
    Assert.assertEquals(nodeIdsOfResourceId.size(), 1);
    // Make sure the node matches the new node
    Assert.assertEquals(Atom.getFirstOrThrow(nodeIdsOfResourceId), Atom.getFirstOrThrow(getHive().directory().getNodeIdsOfPrimaryIndexKey(newPrimaryIndexKey)));
    // Make sure the entity can be fetched on the new node
    Assert.assertNotNull(dao.get(updated.getReportId()));
  }
View Full Code Here

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

  @SuppressWarnings("unchecked")
  @Test
  public void testSaveAll() throws Exception {
    Collection<WeatherReport> reports = new ArrayList<WeatherReport>();
    for (int i = 0; i < 54; i++) {
      WeatherReport report = new GenerateInstance<WeatherReport>(WeatherReport.class).generate();
      GeneratedInstanceInterceptor.setProperty(report, "reportId", i);
      reports.add(report);
    }
    DataAccessObject<WeatherReport, Integer> dao = (DataAccessObject<WeatherReport, Integer>) getDao(getGeneratedClass());
    dao.saveAll(reports);

    for (WeatherReport report : reports)
      assertEquals(report, dao.get(report.getReportId()));
  }
View Full Code Here

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

  }

  @SuppressWarnings("unchecked")
  @Test
  public void testHealDataNodeOnlyRecord() throws Exception {
    WeatherReport report = new GenerateInstance<WeatherReport>(WeatherReport.class).generate();

    DataAccessObject<WeatherReport, Integer> dao = (DataAccessObject<WeatherReport, Integer>) getDao(getGeneratedClass());
    dao.save(report);
    assertEquals(report, dao.get(report.getReportId()));
    Hive hive = getHive();
    hive.directory().deleteResourceId(config.getEntityConfig(getGeneratedClass()).getResourceName(), report.getReportId());
    ReflectionTools.invokeSetter(report, "regionCode", report.getRegionCode() + 1);
    assertFalse(dao.exists(report.getReportId()));
    dao.save(report);
    assertEquals(report, dao.get(report.getReportId()));
  }
View Full Code Here

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

  @SuppressWarnings("unchecked")
  @Test
  public void testHealDataNodeOnlyRecordSaveAll() throws Exception {
    Collection<WeatherReport> reports = new ArrayList<WeatherReport>();
    for (int i = 0; i < 5; i++) {
      WeatherReport report = new GenerateInstance<WeatherReport>(WeatherReport.class).generate();
      GeneratedInstanceInterceptor.setProperty(report, "reportId", i);
      reports.add(report);
    }

    DataAccessObject<WeatherReport, Integer> dao = (DataAccessObject<WeatherReport, Integer>) getDao(getGeneratedClass());
    dao.saveAll(reports);
    for (WeatherReport report : reports)
      assertEquals(report, dao.get(report.getReportId()));

    WeatherReport orphan = Atom.getFirstOrThrow(reports);

    Hive hive = getHive();
    hive.directory().deleteResourceId(config.getEntityConfig(getGeneratedClass()).getResourceName(), orphan.getReportId());
    for (WeatherReport report : reports)
      ReflectionTools.invokeSetter(report, "regionCode", report.getRegionCode() + 1);
    assertFalse(dao.exists(orphan.getReportId()));
    dao.saveAll(reports);

    for (WeatherReport report : reports)
      assertEquals(report, dao.get(report.getReportId()));

    HiveIndexer indexer = new HiveIndexer(getHive());

    dao.delete(orphan.getReportId());
    indexer.insert(config.getEntityConfig(dao.getRespresentedClass()), orphan);

    dao.saveAll(reports);
    for (WeatherReport report : reports)
      assertEquals(report, dao.get(report.getReportId()));
View Full Code Here

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

  @SuppressWarnings("unchecked")
  @Test
  public void testUpdateAll() throws Exception {
    Collection<WeatherReport> reports = new ArrayList<WeatherReport>();
    for (int i = 0; i < 5; i++) {
      WeatherReport report = new GenerateInstance<WeatherReport>(WeatherReport.class).generate();
      GeneratedInstanceInterceptor.setProperty(report, "reportId", i);
      reports.add(report);
    }
    DataAccessObject<WeatherReport, Integer> dao = (DataAccessObject<WeatherReport, Integer>) getDao(getGeneratedClass());
    dao.saveAll(reports);


    Collection<WeatherReport> updated = new ArrayList<WeatherReport>();
    for (WeatherReport report : reports) {
      GeneratedInstanceInterceptor.setProperty(report, "temperature", 100);
      updated.add(report);
    }
    dao.saveAll(updated);

    for (WeatherReport report : updated) {
      final WeatherReport weatherReport = dao.get(report.getReportId());
      assertEquals(report, weatherReport);
    }

    // Test changing the partition dimension key
    String newPrimaryIndexKey = findPrimaryKeyOnDifferentNode(Atom.getFirstOrThrow(reports));
View Full Code Here

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

  @SuppressWarnings("unchecked")
  @Test
  public void testExists() throws Exception {
    DataAccessObject<WeatherReport, Integer> dao = (DataAccessObject<WeatherReport, Integer>) getDao(getGeneratedClass());
    assertFalse(dao.exists(88));
    WeatherReport original = getPersistentInstance(dao);
    assertTrue(dao.exists(original.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.