### Question:
DomainMapper { public String describeDomain() throws ClassNotFoundException { List<Edge> edges = new ArrayList<>(); edges.addAll(fieldScanner.getEdges()); edges.addAll(hierarchyScanner.getEdges()); List<DomainObject> domainObjects = classes.stream().map(DomainObject::new).collect(Collectors.toList()); return presenter.describe(domainObjects, edges); } DomainMapper(final List<Class<?>> classes); String describeDomain(); List<Class<?>> getClasses(); static DomainMapper create(List<String> packages, URLClassLoader classLoader); static DomainMapper create(final List<String> packages);  }### Answer:
@Test public void testDescribeDomain_singleClass() throws ClassNotFoundException { List<Class<?>> list = new ArrayList<>(); list.add(Employee.class); domainMapper = new DomainMapper(list); String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n }\n}"; assertThat(domainMapper.describeDomain(), is(description)); }
@Test public void testDescribeDomain_selfie() throws ClassNotFoundException { List<Class<?>> list = new ArrayList<>(); list.add(Selfie.class); domainMapper = new DomainMapper(list); String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain\";\n Selfie\n }\n Selfie -> Selfie [ taillabel = \"me\" dir=forward arrowhead=open];\n}"; assertThat(domainMapper.describeDomain(), is(description)); }
@Test public void testDescribeDomain_doubleReferer() throws ClassNotFoundException { domainMapper = new DomainMapper(Arrays.asList(DoubleReferer.class, Manager.class)); String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n DoubleReferer\n Manager\n }\n DoubleReferer -> Manager [ taillabel = \"myBoss\" dir=forward arrowhead=open];\n DoubleReferer -> Manager [ taillabel = \"myTeamManager\" dir=forward arrowhead=open];\n}"; assertThat(domainMapper.describeDomain(), is(description)); }
@Test public void testDescribeDomain_simpleInheritance() throws ClassNotFoundException { domainMapper = new DomainMapper(Arrays.<Class<?>>asList(Manager.class, Person.class)); String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain.person\";\n Manager\n Person\n }\n Manager -> Person [arrowhead=empty color=slategray];\n}"; assertThat(domainMapper.describeDomain(), is(description)); }
@Test public void testDescribeDomain() throws ClassNotFoundException { domainMapper = new DomainMapper(Arrays.asList(Employee.class, Task.class, Manager.class, Timesheet.class, Person.class)); String description = DOMAIN_DECLARATION + DEFAULTS + "\n subgraph cluster_0 {\n label = \"com.nitorcreations.testdomain\";\n Task\n Timesheet\n }\n subgraph cluster_1 {\n label = \"com.nitorcreations.testdomain.person\";\n Employee\n Manager\n Person\n }\n Task -> Employee [ taillabel = \"assignedEmployees\" dir=forward arrowhead=open];\n Timesheet -> Employee [ taillabel = \"who\" dir=forward arrowhead=open];\n Task -> Manager [ taillabel = \"manager\" dir=forward arrowhead=open];\n Timesheet -> Task [ taillabel = \"task\" dir=forward arrowhead=open];\n Employee -> Person [arrowhead=empty color=slategray];\n Manager -> Person [arrowhead=empty color=slategray];\n}"; assertThat(domainMapper.describeDomain(), is(description)); }