/** * Tests population of <code>SettingDTO</code> in the assumption that all other methods are * implemented correctly. */ @Test public void testPopulateDTO() { final SettingDefinitionAdapter settingDefinitionAdapter = new SettingDefinitionAdapter() { @Override List<MetadataDTO> createMetadataDTOList(final SettingDefinition source) { return null; } @Override DefaultValueDTO createDefaultValueDTO(final SettingDefinition source) { return null; } }; final SettingDefinition settingDefinition = context.mock(SettingDefinition.class); final String settingNameSpace = NAMESPACE; final String settingDescription = DESCRIPTION; final int maxOverrides = MAXIMUM_OVERRIDES; context.checking( new Expectations() { { oneOf(settingDefinition).getPath(); will(returnValue(settingNameSpace)); oneOf(settingDefinition).getDescription(); will(returnValue(settingDescription)); oneOf(settingDefinition).getMaxOverrideValues(); will(returnValue(maxOverrides)); } }); final SettingDTO settingDto = new SettingDTO(); settingDefinitionAdapter.populateDTO(settingDefinition, settingDto); assertEquals(settingNameSpace, settingDto.getNameSpace()); assertEquals(settingDescription, settingDto.getDescription()); assertEquals(maxOverrides, settingDto.getMaximumOverrides()); }
/** Tests populateDomain. */ @Test public void testPopulateDomain() { // Expectation final SettingDefinitionAdapter settingDefinitionAdapter = new SettingDefinitionAdapter() { @Override Map<String, SettingMetadata> createSettingMetadataMap( final List<MetadataDTO> metadataValues) { return Collections.emptyMap(); } }; // Checking final SettingDefinition settingDefinition = context.mock(SettingDefinition.class); context.checking( new Expectations() { { oneOf(settingDefinition).setPath(NAMESPACE); oneOf(settingDefinition).setDescription(DESCRIPTION); oneOf(settingDefinition).setMaxOverrideValues(MAXIMUM_OVERRIDES); oneOf(settingDefinition).setValueType(DEFAULT_VALUE_TYPE); oneOf(settingDefinition).setDefaultValue(DEFAULT_VALUE_VALUE); atLeast(1).of(settingDefinition).getMetadata(); will(returnValue(Collections.emptyMap())); oneOf(settingDefinition).setMetadata(Collections.<String, SettingMetadata>emptyMap()); } }); // Test Data SettingDTO settingDTO = new SettingDTO(); settingDTO.setNameSpace(NAMESPACE); settingDTO.setDescription(DESCRIPTION); settingDTO.setMaximumOverrides(MAXIMUM_OVERRIDES); settingDTO.setDefaultValue(createDefaultValue(DEFAULT_VALUE_TYPE, DEFAULT_VALUE_VALUE)); settingDTO.setMetadataValues(Collections.<MetadataDTO>emptyList()); // Result settingDefinitionAdapter.populateDomain(settingDTO, settingDefinition); }