Search in sources :

Example 1 with ConfigurationResponse

use of io.gravitee.rest.api.portal.rest.model.ConfigurationResponse in project gravitee-management-rest-api by gravitee-io.

the class ConfigurationMapperTest method testConvert.

@Test
public void testConvert() throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    PortalSettingsEntity portalSettingsEntity = mapper.readValue(this.getClass().getResourceAsStream("portalSettingsEntity.json"), PortalSettingsEntity.class);
    ConsoleSettingsEntity consoleSettingsEntity = mapper.readValue(this.getClass().getResourceAsStream("consoleSettingsEntity.json"), ConsoleSettingsEntity.class);
    String expected = IOUtils.toString(this.getClass().getResourceAsStream("expectedPortalConfiguration.json"), "UTF-8");
    ConfigurationMapper configurationMapper = new ConfigurationMapper();
    ConfigurationResponse configuration = configurationMapper.convert(portalSettingsEntity, consoleSettingsEntity);
    mapper.setSerializationInclusion(Include.NON_NULL);
    mapper.configure(SerializationFeature.INDENT_OUTPUT, true);
    String configurationAsJSON = mapper.writeValueAsString(configuration);
    assertEquals(expected.trim(), configurationAsJSON.trim());
}
Also used : PortalSettingsEntity(io.gravitee.rest.api.model.settings.PortalSettingsEntity) ConsoleSettingsEntity(io.gravitee.rest.api.model.settings.ConsoleSettingsEntity) ConfigurationResponse(io.gravitee.rest.api.portal.rest.model.ConfigurationResponse) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ConsoleSettingsEntity (io.gravitee.rest.api.model.settings.ConsoleSettingsEntity)1 PortalSettingsEntity (io.gravitee.rest.api.model.settings.PortalSettingsEntity)1 ConfigurationResponse (io.gravitee.rest.api.portal.rest.model.ConfigurationResponse)1 Test (org.junit.Test)1