NodeMapper { public static NodeDTO toDTO(Node node, DependencyGraph dependencyGraph) { checkNotNull(node, "node"); checkNotNull(dependencyGraph, "dependencyGraph"); NodeDTO result = new NodeDTO(); mapProperties(node, result); mapHierarchy(node, dependencyGraph, result); mapDependencies(result, node, dependencyGraph); return result; } private  NodeMapper(); static NodeDTO toDTO(Node node, DependencyGraph dependencyGraph);  }
@Test public void toDTO() { Node node = dependencyGraph.getNode("v1"); NodeDTO nodeDTO = NodeMapper.toDTO(node, dependencyGraph); assertThat(nodeDTO.getName(), is("v1")); assertThat(nodeDTO.getOutgoingDeps(), hasSize(2)); assertThat(nodeDTO.getOutgoingDeps().get(0).getSourceName(), is("v1")); assertThat(nodeDTO.getOutgoingDeps().get(0).getTargetName(), is("v2")); assertThat(nodeDTO.getOutgoingDeps().get(0).getTypeName(), is("READ_ONLY")); assertThat(nodeDTO.getParents(), hasSize(1)); assertThat(nodeDTO.getParents().get(0).getSourceName(), is("p1")); }
@Test public void toDTOParent() { Node p1 = dependencyGraph.getNode("p1"); NodeDTO nodeDTO = NodeMapper.toDTO(p1, dependencyGraph); assertThat(nodeDTO.getName(), is("p1")); assertThat(nodeDTO.getContainedDeps(), hasSize(1)); assertThat(nodeDTO.getContainedDeps().get(0).getSourceName(), is("p1")); assertThat(nodeDTO.getContainedDeps().get(0).getTargetName(), is("v1")); assertThat(nodeDTO.getContainedDeps().get(0).getTypeName(), is("CONTAINS")); assertThat(nodeDTO.getParents(), hasSize(0)); }
@Test(expected = NullPointerException.class) public void testNullInput() { NodeMapper.toDTO(null, dependencyGraph); }
@Test(expected = NullPointerException.class) public void testNullInput2() { Node node = dependencyGraph.getNode("v1"); NodeMapper.toDTO(node, null); }