Ejemplo n.º 1
0
  @Test
  public void getConsumptions() throws IOException, VscaleException {
    Result<ConsumptionList> query =
        this.api.consumptions(new Date(1443657600000L), new Date(1448928000000L));

    ConsumptionList consumptionList = query.get();
    assertNotNull(consumptionList);

    assertNotNull(consumptionList.getConsumptions());

    assertTrue(consumptionList.getConsumptions().size() > 0);

    Map<Long, Consumption> consumptions = consumptionList.getConsumptions();

    for (Map.Entry<Long, Consumption> entry : consumptions.entrySet()) {
      assertNotNull(entry.getKey());
      assertNotNull(entry.getValue());

      Consumption consumption = entry.getValue();

      assertNotNull(consumption.getTotal());
      assertNotNull(consumption.getItems());

      assertTrue(consumption.getItems().size() > 0);

      Map<String, ConsumptionItem> items = consumption.getItems();

      for (Map.Entry<String, ConsumptionItem> itemEntry : items.entrySet()) {
        assertNotNull(itemEntry.getKey());
        assertNotNull(itemEntry.getValue());

        ConsumptionItem consumptionItem = itemEntry.getValue();

        assertNotNull(consumptionItem.getCount());
        assertNotNull(consumptionItem.getSum());
      }
    }
  }