### Question:
NetworkInfoMapper { public NetworkInfo map() { final NetworkInfo info = new NetworkInfo(); if (network == null) { info.setStatus(NetworkStatus.NOTFOUND); } else { info.setName(network.getName()); info.setId(network.getId()); info.setStatus(this.mapStatus(network.getStatus())); Pair<Optional<String>, List<Integer>> result = locateVlanInformation(network); Optional<String> value0 = result.getValue0(); if (value0.isPresent()) { info.setProvider(value0.get()); } info.setVlans(result.getValue1()); info.setSubnets(network.getSubnets()); } return info; } NetworkInfoMapper(Network network); NetworkInfo map();  }### Answer:
@Test public void checkLocateVlanInformationNoSegments() { Network network = new Network(); network.setProviderPhysicalNetwork("test-physical-network"); network.setProviderNetworkType("vlan"); network.setProviderSegmentationId(2); NetworkInfoMapper mapper = new NetworkInfoMapper(network); NetworkInfo result = mapper.map(); assertEquals("test-physical-network", result.getProvider()); assertEquals(1, result.getVlans().size()); assertEquals(2, result.getVlans().get(0).intValue()); }
@Test public void checkLocateVlanInformationSegments() { Network network = new Network(); addSegments(network); NetworkInfoMapper mapper = new NetworkInfoMapper(network); NetworkInfo result = mapper.map(); assertEquals("type1", result.getProvider()); assertEquals(2, result.getVlans().size()); assertEquals(Arrays.asList(1, 2).toString(), result.getVlans().toString()); }
@Test public void checkLocateVlanInformationSegmentsAndPhysical() { Network network = new Network(); addSegments(network); network.setProviderPhysicalNetwork("test-physical-network"); network.setProviderNetworkType("vlan"); network.setProviderSegmentationId(2); NetworkInfoMapper mapper = new NetworkInfoMapper(network); NetworkInfo result = mapper.map(); assertEquals("test-physical-network", result.getProvider()); assertEquals(1, result.getVlans().size()); assertEquals(2, result.getVlans().get(0).intValue()); }
@Test public void nullNetwork() { NetworkInfoMapper mapper = new NetworkInfoMapper(null); assertEquals(NetworkStatus.NOTFOUND, mapper.map().getStatus()); }
@Test public void mapFields() { Network network = new Network(); network.setId("id"); network.setName("name"); network.setSubnets(Arrays.asList("string1", "string2")); NetworkInfoMapper mapper = new NetworkInfoMapper(network); NetworkInfo mapped = mapper.map(); assertEquals("name", mapped.getName()); assertEquals("id", mapped.getId()); assertEquals(network.getSubnets(), mapped.getSubnets()); }