use of com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel in project hub-alert by blackducksoftware.
the class DescriptorMetadataActions method createDescriptorResponse.
private ActionResponse<DescriptorsResponseModel> createDescriptorResponse(Predicate<Descriptor> descriptorFilter, Set<ConfigContextEnum> requestedContexts) {
Set<DescriptorMetadata> descriptorMetadata = descriptors.stream().filter(descriptorFilter).map(descriptor -> createDescriptorMetadata(descriptor, requestedContexts)).flatMap(Set::stream).collect(Collectors.toSet());
DescriptorsResponseModel responseModel = new DescriptorsResponseModel(descriptorMetadata);
return new ActionResponse<>(HttpStatus.OK, responseModel);
}
use of com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel in project hub-alert by blackducksoftware.
the class DescriptorControllerTestIT method getDescriptorsWithNameAndContextTest.
@Test
public void getDescriptorsWithNameAndContextTest() throws Exception {
String msTeams = ChannelKeys.MS_TEAMS.getUniversalKey();
URI descriptorPath = new URIBuilder(DescriptorController.BASE_PATH).addParameter("name", msTeams).addParameter("context", ConfigContextEnum.GLOBAL.name()).build();
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.get(descriptorPath).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
DescriptorsResponseModel descriptorsResponseModel = assertValidResponse(request);
assertEquals(1, descriptorsResponseModel.getDescriptors().size());
}
use of com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel in project hub-alert by blackducksoftware.
the class DescriptorControllerTestIT method getDescriptorsWithNoParametersTest.
@Test
public void getDescriptorsWithNoParametersTest() throws Exception {
MockHttpServletRequestBuilder request = MockMvcRequestBuilders.get(new URI(DescriptorController.BASE_PATH)).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
DescriptorsResponseModel descriptorsResponseModel = assertValidResponse(request);
assertEquals(21, descriptorsResponseModel.getDescriptors().size());
}
use of com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel in project hub-alert by blackducksoftware.
the class AboutReaderTest method initialize.
@BeforeEach
public void initialize() {
alertWebServerUrlManager = Mockito.mock(AlertWebServerUrlManager.class);
Mockito.when(alertWebServerUrlManager.getServerComponentsBuilder()).thenReturn(UriComponentsBuilder.newInstance());
defaultSystemStatusUtility = Mockito.mock(DefaultSystemStatusAccessor.class);
Mockito.when(defaultSystemStatusUtility.isSystemInitialized()).thenReturn(Boolean.TRUE);
Mockito.when(defaultSystemStatusUtility.getStartupTime()).thenReturn(DateUtils.createCurrentDateTimestamp());
defaultSystemMessageUtility = Mockito.mock(DefaultSystemMessageAccessor.class);
Mockito.when(defaultSystemMessageUtility.getSystemMessages()).thenReturn(Collections.singletonList(new SystemMessageModel("1", RestConstants.formatDate(new Date()), "ERROR", "startup errors", "type")));
descriptorMetadataActions = Mockito.mock(DescriptorMetadataActions.class);
DescriptorsResponseModel descriptorsResponseModel = new DescriptorsResponseModel(Set.of(Mockito.mock(DescriptorMetadata.class), Mockito.mock(DescriptorMetadata.class)));
Mockito.when(descriptorMetadataActions.getDescriptorsByType(Mockito.anyString())).thenReturn(new ActionResponse<>(HttpStatus.OK, descriptorsResponseModel));
}
use of com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel in project hub-alert by blackducksoftware.
the class DescriptorMetadataActionsTest method getDescriptorsWithNameAndContextTest.
@Test
public void getDescriptorsWithNameAndContextTest() {
String componentName1 = getNamePrefix(DescriptorType.CHANNEL) + "_4";
ConfigContextEnum context1 = ConfigContextEnum.GLOBAL;
ActionResponse<DescriptorsResponseModel> response1 = actions.getDescriptorsByPermissions(componentName1, null, context1.name());
assertTrue(response1.isSuccessful());
assertTrue(response1.hasContent());
Set<DescriptorMetadata> descriptorMetadata1 = response1.getContent().get().getDescriptors();
assertEquals(1, descriptorMetadata1.size());
String componentName2 = getNamePrefix(DescriptorType.COMPONENT) + "_4";
ConfigContextEnum context2 = ConfigContextEnum.GLOBAL;
ActionResponse<DescriptorsResponseModel> response2 = actions.getDescriptorsByPermissions(componentName2, null, context2.name());
assertTrue(response2.isSuccessful());
assertTrue(response2.hasContent());
Set<DescriptorMetadata> descriptorMetadata2 = response2.getContent().get().getDescriptors();
assertEquals(1, descriptorMetadata2.size());
String componentName3 = getNamePrefix(DescriptorType.PROVIDER) + "_4";
ConfigContextEnum context3 = ConfigContextEnum.GLOBAL;
ActionResponse<DescriptorsResponseModel> response3 = actions.getDescriptorsByPermissions(componentName3, null, context3.name());
assertTrue(response3.isSuccessful());
assertTrue(response3.hasContent());
Set<DescriptorMetadata> descriptorMetadata3 = response3.getContent().get().getDescriptors();
assertEquals(1, descriptorMetadata3.size());
ConfigContextEnum context4 = ConfigContextEnum.DISTRIBUTION;
ActionResponse<DescriptorsResponseModel> response4 = actions.getDescriptorsByPermissions(componentName1, null, context4.name());
assertTrue(response4.isSuccessful());
assertTrue(response4.hasContent());
Set<DescriptorMetadata> descriptorMetadata4 = response4.getContent().get().getDescriptors();
assertEquals(1, descriptorMetadata4.size());
ConfigContextEnum context5 = ConfigContextEnum.DISTRIBUTION;
ActionResponse<DescriptorsResponseModel> response5 = actions.getDescriptorsByPermissions(componentName2, null, context5.name());
assertTrue(response5.isSuccessful());
assertTrue(response5.hasContent());
Set<DescriptorMetadata> descriptorMetadata5 = response5.getContent().get().getDescriptors();
assertEquals(1, descriptorMetadata5.size());
ConfigContextEnum context6 = ConfigContextEnum.DISTRIBUTION;
ActionResponse<DescriptorsResponseModel> response6 = actions.getDescriptorsByPermissions(componentName3, null, context6.name());
assertTrue(response6.isSuccessful());
assertTrue(response6.hasContent());
Set<DescriptorMetadata> descriptorMetadata6 = response6.getContent().get().getDescriptors();
assertEquals(1, descriptorMetadata6.size());
}
Aggregations