Search in sources :

Example 1 with ResourceMetadata

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);
}
Also used : PolicyViolationContentItem(com.blackducksoftware.integration.hub.notification.PolicyViolationContentItem) ComponentVersionView(com.blackducksoftware.integration.hub.api.generated.view.ComponentVersionView) PolicyRuleView(com.blackducksoftware.integration.hub.api.generated.view.PolicyRuleView) ProjectVersionModel(com.blackducksoftware.integration.hub.notification.ProjectVersionModel) ResourceMetadata(com.blackducksoftware.integration.hub.api.generated.component.ResourceMetadata) Date(java.util.Date) Test(org.junit.Test)

Example 2 with ResourceMetadata

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);
}
Also used : PolicyViolationContentItem(com.blackducksoftware.integration.hub.notification.PolicyViolationContentItem) PolicyRuleView(com.blackducksoftware.integration.hub.api.generated.view.PolicyRuleView) ProjectVersionModel(com.blackducksoftware.integration.hub.notification.ProjectVersionModel) ResourceMetadata(com.blackducksoftware.integration.hub.api.generated.component.ResourceMetadata) Date(java.util.Date) Test(org.junit.Test)

Example 3 with ResourceMetadata

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());
}
Also used : ArrayList(java.util.ArrayList) HubServicesFactory(com.blackducksoftware.integration.hub.service.HubServicesFactory) ResourceMetadata(com.blackducksoftware.integration.hub.api.generated.component.ResourceMetadata) Logger(org.slf4j.Logger) HubGroup(com.blackducksoftware.integration.hub.alert.hub.model.HubGroup) UserGroupView(com.blackducksoftware.integration.hub.api.generated.view.UserGroupView) GlobalProperties(com.blackducksoftware.integration.hub.alert.config.GlobalProperties) HubService(com.blackducksoftware.integration.hub.service.HubService) Test(org.junit.Test)

Aggregations

ResourceMetadata (com.blackducksoftware.integration.hub.api.generated.component.ResourceMetadata)3 Test (org.junit.Test)3 PolicyRuleView (com.blackducksoftware.integration.hub.api.generated.view.PolicyRuleView)2 PolicyViolationContentItem (com.blackducksoftware.integration.hub.notification.PolicyViolationContentItem)2 ProjectVersionModel (com.blackducksoftware.integration.hub.notification.ProjectVersionModel)2 Date (java.util.Date)2 GlobalProperties (com.blackducksoftware.integration.hub.alert.config.GlobalProperties)1 HubGroup (com.blackducksoftware.integration.hub.alert.hub.model.HubGroup)1 ComponentVersionView (com.blackducksoftware.integration.hub.api.generated.view.ComponentVersionView)1 UserGroupView (com.blackducksoftware.integration.hub.api.generated.view.UserGroupView)1 HubService (com.blackducksoftware.integration.hub.service.HubService)1 HubServicesFactory (com.blackducksoftware.integration.hub.service.HubServicesFactory)1 ArrayList (java.util.ArrayList)1 Logger (org.slf4j.Logger)1