use of com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel in project hub-alert by blackducksoftware.
the class AboutReader method getDescriptorData.
private Set<DescriptorMetadata> getDescriptorData(DescriptorType descriptorType) {
Set<DescriptorMetadata> descriptorData = Set.of();
ActionResponse<DescriptorsResponseModel> response = descriptorActions.getDescriptorsByType(descriptorType.name());
if (response.hasContent()) {
DescriptorsResponseModel providersData = response.getContent().get();
descriptorData = providersData.getDescriptors();
}
return descriptorData;
}
use of com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel in project hub-alert by blackducksoftware.
the class DescriptorMetadataActionsTest method getDescriptorsWithAllParametersTest.
@Test
public void getDescriptorsWithAllParametersTest() {
DescriptorType type1 = DescriptorType.CHANNEL;
String componentName1 = getNamePrefix(type1) + "_2";
ConfigContextEnum context1 = ConfigContextEnum.GLOBAL;
ActionResponse<DescriptorsResponseModel> response1 = actions.getDescriptorsByPermissions(componentName1, type1.name(), context1.name());
assertTrue(response1.isSuccessful());
assertTrue(response1.hasContent());
Set<DescriptorMetadata> descriptorMetadata1 = response1.getContent().get().getDescriptors();
assertEquals(1, descriptorMetadata1.size());
}
use of com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel in project hub-alert by blackducksoftware.
the class DescriptorControllerTestIT method getDescriptorsWithAllParametersTest.
@Test
public void getDescriptorsWithAllParametersTest() throws Exception {
String msTeams = ChannelKeys.MS_TEAMS.getUniversalKey();
URI descriptorPath = new URIBuilder(DescriptorController.BASE_PATH).addParameter("name", msTeams).addParameter("type", DescriptorType.CHANNEL.name()).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 assertValidResponse.
private DescriptorsResponseModel assertValidResponse(MockHttpServletRequestBuilder request) throws Exception {
MvcResult mvcResult = mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isOk()).andReturn();
String listOfDescriptorsJson = mvcResult.getResponse().getContentAsString();
DescriptorsResponseModel descriptorsResponseModel = new Gson().fromJson(listOfDescriptorsJson, DescriptorsResponseModel.class);
Set<DescriptorMetadata> setOfDescriptors = descriptorsResponseModel.getDescriptors();
assertTrue(setOfDescriptors.size() > 0);
return descriptorsResponseModel;
}
use of com.synopsys.integration.alert.web.api.metadata.model.DescriptorsResponseModel in project hub-alert by blackducksoftware.
the class DescriptorMetadataActions method getDescriptorsByPermissions.
public ActionResponse<DescriptorsResponseModel> getDescriptorsByPermissions(@Nullable String name, @Nullable String type, @Nullable String context) {
Predicate<Descriptor> descriptorFilter = ignored -> true;
Set<ConfigContextEnum> requestedContexts = Set.of(ConfigContextEnum.GLOBAL, ConfigContextEnum.DISTRIBUTION);
if (StringUtils.isNotBlank(name)) {
descriptorFilter = descriptorFilter.and(descriptor -> name.equals(descriptor.getDescriptorKey().getUniversalKey()));
}
if (StringUtils.isNotBlank(type)) {
descriptorFilter = descriptorFilter.and(descriptor -> type.equals(descriptor.getType().name()));
}
if (StringUtils.isNotBlank(context)) {
ConfigContextEnum requestedContext = EnumUtils.getEnum(ConfigContextEnum.class, context);
if (null != requestedContext) {
requestedContexts = Set.of(requestedContext);
} else {
requestedContexts = Set.of();
}
}
return createDescriptorResponse(descriptorFilter, requestedContexts);
}
Aggregations