- @Test
- public void checkNetworkStatusMap() {
- NetworkInfoMapper mapper = new NetworkInfoMapper(new Network());
- assertEquals(NetworkStatus.ACTIVE, mapper.mapStatus("ACTIVE"));
- assertEquals(NetworkStatus.BUILD, mapper.mapStatus("BUILD"));
- assertEquals(NetworkStatus.ERROR, mapper.mapStatus("ERROR"));
- assertEquals(NetworkStatus.DOWN, mapper.mapStatus("DOWN"));
- assertEquals(NetworkStatus.UNKNOWN, mapper.mapStatus("NOT IN MAP"));
- assertEquals(NetworkStatus.UNKNOWN, mapper.mapStatus(null));
- }
-
- @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);
+ @Test
+ public void checkNetworkStatusMap() {
+ NetworkInfoMapper mapper = new NetworkInfoMapper(new Network());
+ assertEquals(NetworkStatus.ACTIVE, mapper.mapStatus("ACTIVE"));
+ assertEquals(NetworkStatus.BUILD, mapper.mapStatus("BUILD"));
+ assertEquals(NetworkStatus.ERROR, mapper.mapStatus("ERROR"));
+ assertEquals(NetworkStatus.DOWN, mapper.mapStatus("DOWN"));
+ assertEquals(NetworkStatus.UNKNOWN, mapper.mapStatus("NOT IN MAP"));
+ assertEquals(NetworkStatus.UNKNOWN, mapper.mapStatus(null));
+ }
+
+ @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());
+ }