use of com.blackducksoftware.integration.hub.api.generated.component.ResourceMetadata in project hub-alert by blackducksoftware.
the class PolicyViolationProcessorTest method testProcess.
@Test
public void testProcess() throws HubIntegrationException, URISyntaxException {
final Date createdAt = new Date();
final ProjectVersionModel projectVersionModel = new ProjectVersionModel();
final String componentName = "Content item test";
final ComponentVersionView componentVersionView = new ComponentVersionView();
final String componentUrl = "url";
final String componentVersionUrl = "newest";
final PolicyRuleView policyRuleView = new PolicyRuleView();
final ResourceMetadata metaView = new ResourceMetadata();
metaView.href = "Meta href";
policyRuleView._meta = metaView;
final List<PolicyRuleView> policyRuleList = Arrays.asList(policyRuleView);
final String componentIssueUrl = "issueUrl";
final PolicyViolationContentItem notification = new PolicyViolationContentItem(createdAt, projectVersionModel, componentName, componentVersionView, componentUrl, componentVersionUrl, policyRuleList, componentIssueUrl);
processTestRun(notification);
}
use of com.blackducksoftware.integration.hub.api.generated.component.ResourceMetadata in project hub-alert by blackducksoftware.
the class PolicyViolationProcessorTest method testProcessWithoutVersion.
@Test
public void testProcessWithoutVersion() throws URISyntaxException, HubIntegrationException {
final Date createdAt = new Date();
final ProjectVersionModel projectVersionModel = new ProjectVersionModel();
final String componentName = "Content item test";
final String componentUrl = "url";
final String componentVersionUrl = "newest";
final PolicyRuleView policyRuleView = new PolicyRuleView();
final ResourceMetadata metaView = new ResourceMetadata();
metaView.href = "Meta href";
policyRuleView._meta = metaView;
final List<PolicyRuleView> policyRuleList = Arrays.asList(policyRuleView);
final String componentIssueUrl = "issueUrl";
final PolicyViolationContentItem notification = new PolicyViolationContentItem(createdAt, projectVersionModel, componentName, null, componentUrl, componentVersionUrl, policyRuleList, componentIssueUrl);
processTestRun(notification);
}
use of com.blackducksoftware.integration.hub.api.generated.component.ResourceMetadata in project hub-alert by blackducksoftware.
the class HubDataActionsTest method testGetHubGroups.
@Test
public void testGetHubGroups() throws Exception {
final GlobalProperties globalProperties = Mockito.mock(GlobalProperties.class);
final HubServicesFactory hubServicesFactory = Mockito.mock(HubServicesFactory.class);
final HubService hubService = Mockito.mock(HubService.class);
final List<UserGroupView> userGroups = new ArrayList<>();
final Boolean active = true;
final String username = "User";
final String href = "href";
final UserGroupView userGroup = new UserGroupView();
final ResourceMetadata metaView = new ResourceMetadata();
metaView.href = href;
userGroup._meta = metaView;
userGroup.active = active;
userGroup.name = username;
userGroups.add(userGroup);
Mockito.when(hubService.getAllResponses(ApiDiscovery.USERGROUPS_LINK_RESPONSE)).thenReturn(userGroups);
Mockito.when(hubServicesFactory.createHubService()).thenReturn(hubService);
Mockito.when(hubServicesFactory.createHubService()).thenReturn(hubService);
Mockito.when(globalProperties.createHubServicesFactory(Mockito.any(Logger.class))).thenReturn(hubServicesFactory);
final HubDataActions hubDataActions = new HubDataActions(globalProperties);
final List<HubGroup> hubGroups = hubDataActions.getHubGroups();
assertEquals(1, hubGroups.size());
final HubGroup hubGroup = hubGroups.get(0);
assertEquals(active, hubGroup.getActive());
assertEquals(username, hubGroup.getName());
assertEquals(href, hubGroup.getUrl());
}
Aggregations