Search in sources :

Example 6 with ApiAction

use of com.synopsys.integration.alert.common.action.ApiAction in project hub-alert by blackducksoftware.

the class DefaultDescriptorGlobalConfigUtilityTest method testGetFieldModel.

@Test
public void testGetFieldModel() throws Exception {
    DescriptorKey descriptorKey = createDescriptorKey();
    FieldModel fieldModel = new FieldModel(descriptorKey.getUniversalKey(), ConfigContextEnum.GLOBAL.name(), Map.of());
    ConfigurationModelConfigurationAccessor configurationModelConfigurationAccessor = Mockito.mock(ConfigurationModelConfigurationAccessor.class);
    ConfigurationFieldModelConverter converter = Mockito.mock(ConfigurationFieldModelConverter.class);
    ConfigurationModel configurationModel = Mockito.mock(ConfigurationModel.class);
    ApiAction apiAction = Mockito.mock(ApiAction.class);
    Mockito.when(configurationModelConfigurationAccessor.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, configurationModelConfigurationAccessor, apiAction, converter);
    FieldModel actualFieldModel = configUtility.getFieldModel().orElse(null);
    assertEquals(fieldModel, actualFieldModel);
}
Also used : ConfigurationModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationModel) ApiAction(com.synopsys.integration.alert.common.action.ApiAction) DescriptorKey(com.synopsys.integration.alert.descriptor.api.model.DescriptorKey) ConfigurationFieldModel(com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel) FieldModel(com.synopsys.integration.alert.common.rest.model.FieldModel) ConfigurationModelConfigurationAccessor(com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor) ConfigContextEnum(com.synopsys.integration.alert.common.enumeration.ConfigContextEnum) ConfigurationFieldModelConverter(com.synopsys.integration.alert.common.persistence.util.ConfigurationFieldModelConverter) Test(org.junit.jupiter.api.Test)

Aggregations

ApiAction (com.synopsys.integration.alert.common.action.ApiAction)6 ConfigContextEnum (com.synopsys.integration.alert.common.enumeration.ConfigContextEnum)5 ConfigurationModelConfigurationAccessor (com.synopsys.integration.alert.common.persistence.accessor.ConfigurationModelConfigurationAccessor)5 ConfigurationFieldModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationFieldModel)5 ConfigurationModel (com.synopsys.integration.alert.common.persistence.model.ConfigurationModel)5 ConfigurationFieldModelConverter (com.synopsys.integration.alert.common.persistence.util.ConfigurationFieldModelConverter)5 FieldModel (com.synopsys.integration.alert.common.rest.model.FieldModel)5 DescriptorKey (com.synopsys.integration.alert.descriptor.api.model.DescriptorKey)5 Test (org.junit.jupiter.api.Test)5