DocumentationConfigurer { public Documentation configureDocumentation() { Documentation documentation = new Documentation(); configureDataDictionary(documentation); configureAddressDocumentation(documentation); configureBblDocumentation(documentation); configureBinDocumentation(documentation); configureBlockfaceDocumentation(documentation); configureIntersectionDocumentation(documentation); configurePlaceDocumentation(documentation); return documentation; } DocumentationConfigurer(GeosupportConfig geosupportConfig, LatLongEnhancer latLongEnhancer); Documentation configureDocumentation();  }
@Test public void testConfigureDocumentation() { GeosupportConfig geosupportConfigMock = Mockito.mock(GeosupportConfig.class); DataDictionary dataDictionary = new DataDictionary(new ArrayList<ItemDocumentation>()); Mockito.when(geosupportConfigMock.getDataDictionary()).thenReturn(dataDictionary); FunctionDocumentation addressDocumentation = new FunctionDocumentation(); addressDocumentation.setId(Function.F1B); addressDocumentation.setDisplayName("address"); addressDocumentation.setFields(new TreeSet<ItemDocumentation>()); Mockito.when(geosupportConfigMock.getFunctionDocumentation(Function.F1B)).thenReturn(addressDocumentation); FunctionDocumentation bblDocumentation = new FunctionDocumentation(); bblDocumentation.setId(Function.FBL); bblDocumentation.setFields(new TreeSet<ItemDocumentation>()); Mockito.when(geosupportConfigMock.getFunctionDocumentation(Function.FBL)).thenReturn(bblDocumentation); FunctionDocumentation binDocumentation = new FunctionDocumentation(); binDocumentation.setId(Function.FBN); binDocumentation.setFields(new TreeSet<ItemDocumentation>()); Mockito.when(geosupportConfigMock.getFunctionDocumentation(Function.FBN)).thenReturn(binDocumentation); FunctionDocumentation blockfaceDocumentation = new FunctionDocumentation(); Mockito.when(geosupportConfigMock.getFunctionDocumentation(Function.F3)).thenReturn(blockfaceDocumentation); FunctionDocumentation intersectionDocumentation = new FunctionDocumentation(); intersectionDocumentation.setId(Function.F2); intersectionDocumentation.setFields(new TreeSet<ItemDocumentation>()); Mockito.when(geosupportConfigMock.getFunctionDocumentation(Function.F2)).thenReturn(intersectionDocumentation); LatLongEnhancer latLongEnhancerMock = Mockito.mock(LatLongEnhancer.class); LatLongConfig latLongConfig = LatLongEnhancer.DEFAULT_CONFIGS.get(0); LatLongConfig latLongInternalConfig = LatLongEnhancer.DEFAULT_CONFIGS.get(1); List<ItemDocumentation> expectedLatLongDocs = new ArrayList<ItemDocumentation>(); expectedLatLongDocs.add(latLongConfig.getLatDocumentation()); expectedLatLongDocs.add(latLongConfig.getLongDocumentation()); expectedLatLongDocs.add(latLongInternalConfig.getLatDocumentation()); expectedLatLongDocs.add(latLongInternalConfig.getLongDocumentation()); Mockito.when(latLongEnhancerMock.getItemDocumentation()).thenReturn(expectedLatLongDocs); Documentation result = new DocumentationConfigurer(geosupportConfigMock, latLongEnhancerMock).configureDocumentation(); assertSame(dataDictionary, result.getDataDictionary()); assertSame(addressDocumentation, result.getAddressDocumentation()); assertSame(bblDocumentation, result.getBblDocumentation()); assertSame(binDocumentation, result.getBinDocumentation()); assertSame(blockfaceDocumentation, result.getBlockfaceDocumentation()); assertSame(intersectionDocumentation, result.getIntersectionDocumentation()); assertNotSame(result.getAddressDocumentation(),result.getPlaceDocumentation()); assertSame(addressDocumentation.getId(), result.getPlaceDocumentation().getId()); assertSame(addressDocumentation.getDescription(), result.getPlaceDocumentation().getDescription()); assertEquals(addressDocumentation.getFields(), result.getPlaceDocumentation().getFields()); assertTrue(addressDocumentation.getFields().contains(latLongConfig.getLatDocumentation())); assertTrue(addressDocumentation.getFields().contains(latLongConfig.getLongDocumentation())); assertTrue(addressDocumentation.getFields().contains(latLongInternalConfig.getLatDocumentation())); assertTrue(addressDocumentation.getFields().contains(latLongInternalConfig.getLongDocumentation())); assertTrue(result.getPlaceDocumentation().getFields().contains(latLongConfig.getLatDocumentation())); assertTrue(result.getPlaceDocumentation().getFields().contains(latLongConfig.getLongDocumentation())); assertTrue(result.getPlaceDocumentation().getFields().contains(latLongInternalConfig.getLatDocumentation())); assertTrue(result.getPlaceDocumentation().getFields().contains(latLongInternalConfig.getLongDocumentation())); assertTrue(result.getIntersectionDocumentation().getFields().contains(latLongConfig.getLatDocumentation())); assertTrue(result.getIntersectionDocumentation().getFields().contains(latLongConfig.getLongDocumentation())); assertFalse(result.getIntersectionDocumentation().getFields().contains(latLongInternalConfig.getLatDocumentation())); assertFalse(result.getIntersectionDocumentation().getFields().contains(latLongInternalConfig.getLongDocumentation())); assertFalse(result.getBblDocumentation().getFields().contains(latLongConfig.getLatDocumentation())); assertFalse(result.getBblDocumentation().getFields().contains(latLongConfig.getLongDocumentation())); assertTrue(result.getBblDocumentation().getFields().contains(latLongInternalConfig.getLatDocumentation())); assertTrue(result.getBblDocumentation().getFields().contains(latLongInternalConfig.getLongDocumentation())); assertFalse(result.getBinDocumentation().getFields().contains(latLongConfig.getLatDocumentation())); assertFalse(result.getBinDocumentation().getFields().contains(latLongConfig.getLongDocumentation())); assertTrue(result.getBinDocumentation().getFields().contains(latLongInternalConfig.getLatDocumentation())); assertTrue(result.getBinDocumentation().getFields().contains(latLongInternalConfig.getLongDocumentation())); assertTrue(result.getDataDictionary().getItems().contains(latLongConfig.getLatDocumentation())); assertTrue(result.getDataDictionary().getItems().contains(latLongConfig.getLongDocumentation())); assertTrue(result.getDataDictionary().getItems().contains(latLongInternalConfig.getLatDocumentation())); assertTrue(result.getDataDictionary().getItems().contains(latLongInternalConfig.getLongDocumentation())); assertEquals(Documentation.ADDRESS_FUNCTION,addressDocumentation.getDisplayName()); assertEquals(Documentation.BBL_FUNCTION,bblDocumentation.getDisplayName()); assertEquals(Documentation.BIN_FUNCTION,binDocumentation.getDisplayName()); assertEquals(Documentation.BLOCKFACE_FUNCTION,blockfaceDocumentation.getDisplayName()); assertEquals(Documentation.INTERSECTION_FUNCTION,intersectionDocumentation.getDisplayName()); assertEquals(Documentation.PLACE_FUNCTION,result.getPlaceDocumentation().getDisplayName()); }