@Test
  public void link_linkRelated() {
    String relatedLink = UUID.randomUUID().toString();
    MeterReading meterReading = EspiFactory.newMeterReading();
    meterReading.setUpLink(new LinkType(LinkType.UP, relatedLink));
    resourceService.persist(meterReading);
    UsagePoint usagePoint = factory.createUsagePoint();
    usagePoint.getRelatedLinks().add(new LinkType(LinkType.RELATED, relatedLink));
    resourceService.persist(usagePoint);

    assertThat(meterReading.getUsagePoint(), is(nullValue()));

    linker.link(usagePoint);

    assertThat(meterReading.getUsagePoint(), equalTo(usagePoint));
  }
  @Test
  public void findByMeterReadingId_returnsIntervalBlocks() {
    MeterReading meterReading = new MeterReading();
    meterReading.setUUID(UUID.randomUUID());

    IntervalBlock intervalBlock = new IntervalBlock();
    intervalBlock.setUUID(UUID.randomUUID());

    IntervalBlock intervalBlock1 = new IntervalBlock();
    intervalBlock1.setUUID(UUID.randomUUID());

    meterReading.addIntervalBlock(intervalBlock);
    meterReading.addIntervalBlock(intervalBlock1);

    meterReadingRepository.persist(meterReading);

    assertEquals(2, repository.findAllByMeterReadingId(meterReading.getId()).size());
  }