use of com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata in project hub-alert by blackducksoftware.
the class DescriptorMetadataActions method createDescriptorMetadata.
private Optional<DescriptorMetadata> createDescriptorMetadata(DescriptorKey descriptorKey, ConfigContextEnum context, DescriptorType descriptorType) {
if (authorizationManager.hasPermissions(context, descriptorKey)) {
Set<AccessOperation> operations = gatherDescriptorContextOperations(context, descriptorKey);
boolean readOnly = authorizationManager.isReadOnly(context, descriptorKey);
DescriptorMetadata descriptorMetadata = new DescriptorMetadata(descriptorKey, descriptorType, context, operations, readOnly);
return Optional.of(descriptorMetadata);
}
return Optional.empty();
}
use of com.synopsys.integration.alert.common.descriptor.config.ui.DescriptorMetadata 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.common.descriptor.config.ui.DescriptorMetadata 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.common.descriptor.config.ui.DescriptorMetadata 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.common.descriptor.config.ui.DescriptorMetadata 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);
}
Aggregations