### Question:
ConfigurationModelMutable extends ConfigurationModel { public void put(ConfigurationFieldModel configFieldModel) { Objects.requireNonNull(configFieldModel); String fieldKey = configFieldModel.getFieldKey(); Objects.requireNonNull(fieldKey); if (getConfiguredFields().containsKey(fieldKey)) { ConfigurationFieldModel oldConfigField = getConfiguredFields().get(fieldKey); List<String> values = combine(oldConfigField, configFieldModel); oldConfigField.setFieldValues(values); } else { getConfiguredFields().put(fieldKey, configFieldModel); } } ConfigurationModelMutable(Long registeredDescriptorId, Long descriptorConfigId, String createdAt, String lastUpdated, String context);  ConfigurationModelMutable(Long registeredDescriptorId, Long descriptorConfigId, String createdAt, String lastUpdated, ConfigContextEnum context); void put(ConfigurationFieldModel configFieldModel);  }### Answer:
@Test public void putTest() { final String fieldValue2 = "fieldValue-2"; ConfigurationFieldModel configurationFieldModel2 = ConfigurationFieldModel.create(fieldKey); configurationFieldModel2.setFieldValue(fieldValue2); ConfigurationModelMutable configurationModelMutable = createConfigurationModelMutable(); configurationModelMutable.put(configurationFieldModel); configurationModelMutable.put(configurationFieldModel2); Optional<ConfigurationFieldModel> testConfigurationFieldModelOptional = configurationModelMutable.getField(fieldKey); assertTrue(testConfigurationFieldModelOptional.isPresent()); ArrayList<String> fieldValues = new ArrayList<>(testConfigurationFieldModelOptional.get().getFieldValues()); assertEquals(2, fieldValues.size()); assertTrue(fieldValues.contains(fieldValue)); assertTrue(fieldValues.contains(fieldValue2)); }
@Test public void getFieldTest() { ConfigurationModelMutable configurationModelMutable = new ConfigurationModelMutable(descriptorId, configurationId, createdAt, lastUpdated, configContextEnum.name()); configurationModelMutable.put(configurationFieldModel); Optional<ConfigurationFieldModel> testConfigurationFieldModel = configurationModelMutable.getField(fieldKey); Optional<ConfigurationFieldModel> testConfigurationFieldModelEmpty = configurationModelMutable.getField("badKey"); assertTrue(testConfigurationFieldModel.isPresent()); assertFalse(testConfigurationFieldModelEmpty.isPresent()); assertEquals(configurationFieldModel, testConfigurationFieldModel.get()); }
@Test public void getCopyOfFieldListTest() { ConfigurationModelMutable configurationModelMutable = createConfigurationModelMutable(); configurationModelMutable.put(configurationFieldModel); List<ConfigurationFieldModel> testConfigurationFieldModelList = configurationModelMutable.getCopyOfFieldList(); assertEquals(1, testConfigurationFieldModelList.size()); assertEquals(configurationFieldModel, testConfigurationFieldModelList.get(0)); }
@Test public void getCopyOfKeyToFieldMapTest() { ConfigurationModelMutable configurationModelMutable = createConfigurationModelMutable(); configurationModelMutable.put(configurationFieldModel); Map<String, ConfigurationFieldModel> configurationFieldModelMap = configurationModelMutable.getCopyOfKeyToFieldMap(); assertEquals(1, configurationFieldModelMap.size()); assertEquals(configurationFieldModel, configurationFieldModelMap.get(fieldKey)); }