package com.blackducksoftware.integration.hub.vulnerabilities.api;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

import com.blackducksoftware.integration.hub.api.vulnerabilities.VulnerabilityItem;
import com.blackducksoftware.integration.hub.meta.MetaInformation;
import com.blackducksoftware.integration.hub.meta.MetaLink;

public class VulnerabilityItemTest {
	private final static String ALLOW = "allow1";
	private final static String HREF = "href1";
	private final static String LINK_REL = "rel1";
	private final static String META_LINK = "link1";
	private final static String VULNERABILITYNAME = "vulnName";
	private final static String DESCRIPTION = "aDescription";
	private final static String PUBLISHEDDATE = "2016-09-07";
	private final static String UPDATEDDATE = "2016-09-08";
	private final static double BASESCORE = 1.0;
	private final static double IMPACTSUBSCORE = 2.0;
	private final static double EXPLOITABILITYSUBSCORE = 3.0;
	private final static String SOURCE = "source";
	private final static String SEVERITY = "severity";
	private final static String ACCESSVECTOR = "accessVector";
	private final static String ACCESSCOMPLEXITY = "accessComplexity";
	private final static String AUTHENTICATION = "authentication";
	private final static String CONFIDENTIALITYIMPACT = "confidentialityImpact";
	private final static String INTEGRITYIMPACT = "integrityImpact";
	private final static String AVAILABILTYIMPACT = "availabilityImpact";
	private final static String CWEID = "cweId";

	private MetaInformation createMetaInformation() {
		final List<String> allows = new ArrayList<String>();
		allows.add(ALLOW);
		final MetaLink link = new MetaLink(LINK_REL, META_LINK);
		final List<MetaLink> links = new ArrayList<MetaLink>();
		links.add(link);
		return new MetaInformation(allows, HREF, links);
	}

	@Test
	public void testConstructor() {
		final MetaInformation meta = createMetaInformation();
		final VulnerabilityItem item = new VulnerabilityItem(meta, VULNERABILITYNAME, DESCRIPTION, PUBLISHEDDATE,
				UPDATEDDATE, BASESCORE, IMPACTSUBSCORE, EXPLOITABILITYSUBSCORE, SOURCE, SEVERITY, ACCESSVECTOR,
				ACCESSCOMPLEXITY, AUTHENTICATION, CONFIDENTIALITYIMPACT, INTEGRITYIMPACT, AVAILABILTYIMPACT, CWEID);

		assertNotNull(item);
		assertEquals(meta, item.getMeta());
		assertEquals(VULNERABILITYNAME, item.getVulnerabilityName());
		assertEquals(DESCRIPTION, item.getDescription());
		assertEquals(PUBLISHEDDATE, item.getVulnerabilityPublishedDate());
		assertEquals(UPDATEDDATE, item.getVulnerabilityUpdatedDate());
		assertEquals(BASESCORE, item.getBaseScore(), 0);
		assertEquals(IMPACTSUBSCORE, item.getImpactSubscore(), 0);
		assertEquals(EXPLOITABILITYSUBSCORE, item.getExploitabilitySubscore(), 0);
		assertEquals(SOURCE, item.getSource());
		assertEquals(SEVERITY, item.getSeverity());
		assertEquals(ACCESSVECTOR, item.getAccessVector());
		assertEquals(ACCESSCOMPLEXITY, item.getAccessComplexity());
		assertEquals(AUTHENTICATION, item.getAuthentication());
		assertEquals(CONFIDENTIALITYIMPACT, item.getConfidentialityImpact());
		assertEquals(INTEGRITYIMPACT, item.getIntegrityImpact());
		assertEquals(AVAILABILTYIMPACT, item.getAvailabilityImpact());
		assertEquals(CWEID, item.getCweId());
	}
}

Add the unit test class for the VulnerabilityItem