ConfigurationMapper { public ConfigurationResponse convert(PortalConfigEntity configEntity) { ConfigurationResponse configuration = new ConfigurationResponse(); configuration.setAnalytics(convert(configEntity.getAnalytics())); configuration.setApiReview(convert(configEntity.getApiReview().getEnabled())); configuration.setApplication(convert(configEntity.getApplication())); configuration.setAuthentication(convert(configEntity.getAuthentication())); configuration.setCompany(convert(configEntity.getCompany())); configuration.setDocumentation(convert(configEntity.getDocumentation())); configuration.setPlan(convert(configEntity.getPlan())); configuration.setPortal(convert(configEntity.getPortal(), configEntity.getApplication())); configuration.setScheduler(convert(configEntity.getScheduler())); configuration.setRecaptcha(convert(configEntity.getReCaptcha())); return configuration; }  ConfigurationResponse convert(PortalConfigEntity configEntity);  }
@Test public void testConvert() throws IOException { ObjectMapper mapper = new ObjectMapper(); PortalConfigEntity configEntity = mapper.readValue(this.getClass().getResourceAsStream("portalConfigEntity.json"), PortalConfigEntity.class); String expected = IOUtils.toString(this.getClass().getResourceAsStream("expectedPortalConfiguration.json"), "UTF-8"); ConfigurationMapper configurationMapper = new ConfigurationMapper(); ConfigurationResponse configuration = configurationMapper.convert(configEntity); mapper.setSerializationInclusion(Include.NON_NULL); mapper.configure(SerializationFeature.INDENT_OUTPUT, true); String configurationAsJSON = mapper.writeValueAsString(configuration); assertEquals(expected.trim(), configurationAsJSON.trim()); }