@Test public void testSave() throws Exception { DescriptorKey descriptorKey = createDescriptorKey(); FieldModel fieldModel = new FieldModel(descriptorKey.getUniversalKey(), ConfigContextEnum.GLOBAL.name(), Map.of()); Map<String, ConfigurationFieldModel> configurationFieldModelCollection = Map.of(); ConfigurationAccessor configurationAccessor = Mockito.mock(ConfigurationAccessor.class); ConfigurationFieldModelConverter converter = Mockito.mock(ConfigurationFieldModelConverter.class); ConfigurationModel configurationModel = Mockito.mock(ConfigurationModel.class); ApiAction apiAction = Mockito.mock(ApiAction.class); Mockito.when(configurationAccessor.createConfiguration(Mockito.eq(descriptorKey), Mockito.any(ConfigContextEnum.class), Mockito.anyCollection())).thenReturn(configurationModel); Mockito.when(converter.convertToConfigurationFieldModelMap(Mockito.eq(fieldModel))).thenReturn(configurationFieldModelCollection); Mockito.when(converter.convertToFieldModel(Mockito.any())).thenReturn(fieldModel); Mockito.when(apiAction.beforeSaveAction(Mockito.eq(fieldModel))).thenReturn(fieldModel); Mockito.when(apiAction.afterSaveAction(Mockito.eq(fieldModel))).thenReturn(fieldModel); DefaultDescriptorGlobalConfigUtility configUtility = new DefaultDescriptorGlobalConfigUtility(descriptorKey, configurationAccessor, apiAction, converter); FieldModel savedModel = configUtility.save(fieldModel); assertEquals(fieldModel, savedModel); Mockito.verify(configurationAccessor).createConfiguration(Mockito.eq(descriptorKey), Mockito.eq(ConfigContextEnum.GLOBAL), Mockito.anyCollection()); }
public FieldModel save(FieldModel fieldModel) throws AlertException { FieldModel beforeAction = apiAction.beforeSaveAction(fieldModel); Collection<ConfigurationFieldModel> values = configurationFieldModelConverter.convertToConfigurationFieldModelMap(beforeAction).values(); ConfigurationModel configuration = configurationAccessor.createConfiguration(key, context, values); FieldModel convertedFieldModel = configurationFieldModelConverter.convertToFieldModel(configuration); return apiAction.afterSaveAction(convertedFieldModel); }
DefaultDescriptorGlobalConfigUtility { public FieldModel save(FieldModel fieldModel) throws AlertException { FieldModel beforeAction = apiAction.beforeSaveAction(fieldModel); Collection<ConfigurationFieldModel> values = configurationFieldModelConverter.convertToConfigurationFieldModelMap(beforeAction).values(); ConfigurationModel configuration = configurationAccessor.createConfiguration(key, context, values); FieldModel convertedFieldModel = configurationFieldModelConverter.convertToFieldModel(configuration); return apiAction.afterSaveAction(convertedFieldModel); } }
DefaultDescriptorGlobalConfigUtility { public FieldModel save(FieldModel fieldModel) throws AlertException { FieldModel beforeAction = apiAction.beforeSaveAction(fieldModel); Collection<ConfigurationFieldModel> values = configurationFieldModelConverter.convertToConfigurationFieldModelMap(beforeAction).values(); ConfigurationModel configuration = configurationAccessor.createConfiguration(key, context, values); FieldModel convertedFieldModel = configurationFieldModelConverter.convertToFieldModel(configuration); return apiAction.afterSaveAction(convertedFieldModel); } DefaultDescriptorGlobalConfigUtility(DescriptorKey descriptorKey, ConfigurationAccessor configurationAccessor, ApiAction apiAction,
        ConfigurationFieldModelConverter configurationFieldModelConverter); }
DefaultDescriptorGlobalConfigUtility { public FieldModel save(FieldModel fieldModel) throws AlertException { FieldModel beforeAction = apiAction.beforeSaveAction(fieldModel); Collection<ConfigurationFieldModel> values = configurationFieldModelConverter.convertToConfigurationFieldModelMap(beforeAction).values(); ConfigurationModel configuration = configurationAccessor.createConfiguration(key, context, values); FieldModel convertedFieldModel = configurationFieldModelConverter.convertToFieldModel(configuration); return apiAction.afterSaveAction(convertedFieldModel); } DefaultDescriptorGlobalConfigUtility(DescriptorKey descriptorKey, ConfigurationAccessor configurationAccessor, ApiAction apiAction,
        ConfigurationFieldModelConverter configurationFieldModelConverter); DescriptorKey getKey(); boolean doesConfigurationExist(); Optional<ConfigurationModel> getConfiguration(); Optional<FieldModel> getFieldModel(); FieldModel save(FieldModel fieldModel); FieldModel update(Long id, FieldModel fieldModel); }
DefaultDescriptorGlobalConfigUtility { public FieldModel save(FieldModel fieldModel) throws AlertException { FieldModel beforeAction = apiAction.beforeSaveAction(fieldModel); Collection<ConfigurationFieldModel> values = configurationFieldModelConverter.convertToConfigurationFieldModelMap(beforeAction).values(); ConfigurationModel configuration = configurationAccessor.createConfiguration(key, context, values); FieldModel convertedFieldModel = configurationFieldModelConverter.convertToFieldModel(configuration); return apiAction.afterSaveAction(convertedFieldModel); } DefaultDescriptorGlobalConfigUtility(DescriptorKey descriptorKey, ConfigurationAccessor configurationAccessor, ApiAction apiAction,
        ConfigurationFieldModelConverter configurationFieldModelConverter); DescriptorKey getKey(); boolean doesConfigurationExist(); Optional<ConfigurationModel> getConfiguration(); Optional<FieldModel> getFieldModel(); FieldModel save(FieldModel fieldModel); FieldModel update(Long id, FieldModel fieldModel);  }