@Test public void testGetFieldModel() throws Exception { DescriptorKey descriptorKey = createDescriptorKey(); FieldModel fieldModel = new FieldModel(descriptorKey.getUniversalKey(), ConfigContextEnum.GLOBAL.name(), 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.getConfigurationsByDescriptorKeyAndContext(Mockito.any(DescriptorKey.class), Mockito.any(ConfigContextEnum.class))).thenReturn(List.of(configurationModel)); Mockito.when(converter.convertToFieldModel(Mockito.any())).thenReturn(fieldModel); Mockito.when(apiAction.afterGetAction(Mockito.eq(fieldModel))).thenReturn(fieldModel); DefaultDescriptorGlobalConfigUtility configUtility = new DefaultDescriptorGlobalConfigUtility(descriptorKey, configurationAccessor, apiAction, converter); FieldModel actualFieldModel = configUtility.getFieldModel().orElse(null); assertEquals(fieldModel, actualFieldModel); }
public Optional<FieldModel> getFieldModel() throws AlertException { Optional<ConfigurationModel> configurationModelOptional = getConfiguration(); if (configurationModelOptional.isPresent()) { ConfigurationModel configurationModel = configurationModelOptional.get(); FieldModel fieldModel = configurationFieldModelConverter.convertToFieldModel(configurationModel); return Optional.ofNullable(apiAction.afterGetAction(fieldModel)); } return Optional.empty(); }
DefaultDescriptorGlobalConfigUtility { public Optional<FieldModel> getFieldModel() throws AlertException { Optional<ConfigurationModel> configurationModelOptional = getConfiguration(); if (configurationModelOptional.isPresent()) { ConfigurationModel configurationModel = configurationModelOptional.get(); FieldModel fieldModel = configurationFieldModelConverter.convertToFieldModel(configurationModel); return Optional.ofNullable(apiAction.afterGetAction(fieldModel)); } return Optional.empty(); } }
DefaultDescriptorGlobalConfigUtility { public Optional<FieldModel> getFieldModel() throws AlertException { Optional<ConfigurationModel> configurationModelOptional = getConfiguration(); if (configurationModelOptional.isPresent()) { ConfigurationModel configurationModel = configurationModelOptional.get(); FieldModel fieldModel = configurationFieldModelConverter.convertToFieldModel(configurationModel); return Optional.ofNullable(apiAction.afterGetAction(fieldModel)); } return Optional.empty(); } DefaultDescriptorGlobalConfigUtility(DescriptorKey descriptorKey, ConfigurationAccessor configurationAccessor, ApiAction apiAction,
        ConfigurationFieldModelConverter configurationFieldModelConverter); }
DefaultDescriptorGlobalConfigUtility { public Optional<FieldModel> getFieldModel() throws AlertException { Optional<ConfigurationModel> configurationModelOptional = getConfiguration(); if (configurationModelOptional.isPresent()) { ConfigurationModel configurationModel = configurationModelOptional.get(); FieldModel fieldModel = configurationFieldModelConverter.convertToFieldModel(configurationModel); return Optional.ofNullable(apiAction.afterGetAction(fieldModel)); } return Optional.empty(); } 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 Optional<FieldModel> getFieldModel() throws AlertException { Optional<ConfigurationModel> configurationModelOptional = getConfiguration(); if (configurationModelOptional.isPresent()) { ConfigurationModel configurationModel = configurationModelOptional.get(); FieldModel fieldModel = configurationFieldModelConverter.convertToFieldModel(configurationModel); return Optional.ofNullable(apiAction.afterGetAction(fieldModel)); } return Optional.empty(); } 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);  }