@Override public EndpointSpecificConfigurationDto toDto() { EndpointSpecificConfigurationDto dto = new EndpointSpecificConfigurationDto(); dto.setEndpointKeyHash(this.getEndpointKeyHash()); dto.setConfiguration(this.getConfiguration()); dto.setConfigurationSchemaVersion(this.getConfigurationVersion()); dto.setVersion(this.getVersion()); return dto; }
@Test public void testShouldSaveWithActiveConfigSchemaVersion() { EndpointSpecificConfigurationDto dto = new EndpointSpecificConfigurationDto(); dto.setConfigurationSchemaVersion(null); dto.setEndpointKeyHash(KEY); dto.setConfiguration(CONFIG_BODY); when(endpointServiceMock.findEndpointProfileByKeyHash(KEY)).thenReturn(generateProfile()); when(configurationServiceMock.normalizeAccordingToOverrideConfigurationSchema(APP_ID, CONF_VERSION, CONFIG_BODY)).thenReturn("valid body"); when(daoMock.save(dto)).thenReturn(configuration); when(configuration.toDto()).thenReturn(new EndpointSpecificConfigurationDto()); Assert.assertTrue(SERVICE.save(dto) != null); verify(configurationServiceMock).normalizeAccordingToOverrideConfigurationSchema(APP_ID, CONF_VERSION, CONFIG_BODY); verify(endpointServiceMock).findEndpointProfileByKeyHash(KEY); verify(daoMock).save(dto); }
@Test public void testShouldSaveWithProvidedConfigSchemaVersion() { EndpointSpecificConfigurationDto dto = new EndpointSpecificConfigurationDto(); dto.setConfigurationSchemaVersion(7); dto.setEndpointKeyHash(KEY); dto.setConfiguration(CONFIG_BODY); when(endpointServiceMock.findEndpointProfileByKeyHash(KEY)).thenReturn(generateProfile()); when(configurationServiceMock.normalizeAccordingToOverrideConfigurationSchema(APP_ID, 7, CONFIG_BODY)).thenReturn("valid body"); when(daoMock.save(dto)).thenReturn(configuration); when(configuration.toDto()).thenReturn(new EndpointSpecificConfigurationDto()); Assert.assertTrue(SERVICE.save(dto) != null); verify(configurationServiceMock).normalizeAccordingToOverrideConfigurationSchema(APP_ID, 7, CONFIG_BODY); verify(endpointServiceMock).findEndpointProfileByKeyHash(KEY); verify(daoMock).save(dto); }
@Override public EndpointSpecificConfigurationDto toDto() { EndpointSpecificConfigurationDto dto = new EndpointSpecificConfigurationDto(); dto.setEndpointKeyHash(getBytes(this.getEndpointKeyHash())); dto.setConfiguration(this.getConfiguration()); dto.setConfigurationSchemaVersion(this.getConfigurationVersion()); dto.setVersion(this.getVersion()); return dto; }