UrlRunIndexWrapper extends RunIndexWrapper<Url> { @Override public List<UrlPacket> getUrlPackets() { Suite suite = objectToRunWrapper.getRealSuite(); Optional<Test> test = objectToRunWrapper.getRealSuite() .getTest(objectToRunWrapper.getTestName()); if (test.isPresent()) { UrlPacket packet = new UrlPacket(suite, test.get()); packet.addUrl(objectToRunWrapper.getObjectToRun()); return Collections.singletonList(packet); } return Collections.emptyList(); } UrlRunIndexWrapper(Run<Url> objectToRunWrapper); @Override List<UrlPacket> getUrlPackets(); @Override int countUrls();  }
@Test public void getUrlPackets_expectOne() { test = Optional .of(new com.cognifide.aet.communication.api.metadata.Test("testName", "proxy", "chrome")); url = Optional.of(new Url("urlName", "urlUrl", "urlDomain")); when(objectToRunWrapper.getRealSuite()).thenReturn(suite); when(suite.getTest(any(String.class))).thenReturn(test); when(objectToRunWrapper.getObjectToRun()).thenReturn(url.get()); List<UrlPacket> packets = urlRunIndexWrapper.getUrlPackets(); Long urlsCount = packets.stream().map(UrlPacket::getUrls).mapToLong(List::size).sum(); assertThat(urlsCount, is(1L)); }