Skip to content

Commit

Permalink
ConDec-132: Minor refactoring in order to release version 2.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
kleebaum committed May 5, 2018
1 parent 0c337cc commit 40dde79
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 275 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>de.uhd.ifi.se.decision</groupId>
<artifactId>documentation.jira</artifactId>
<version>2.0.8</version>
<version>2.0.9</version>
<organization>
<name>Software Engineering Research Group, Heidelberg University</name>
<url>https://github.com/cures-hub</url>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package de.uhd.ifi.se.decision.documentation.jira.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.atlassian.jira.component.ComponentAccessor;
Expand All @@ -13,12 +11,6 @@

public class Projects {

List<DecisionKnowledgeProject> projects;

public Projects() {
this.projects = new ArrayList<DecisionKnowledgeProject>();
}

public static Map<String, DecisionKnowledgeProject> getProjectsMap() {
Map<String, DecisionKnowledgeProject> configMap = new HashMap<String, DecisionKnowledgeProject>();
for (Project project : ComponentAccessor.getProjectManager().getProjects()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,30 @@
import de.uhd.ifi.se.decision.documentation.jira.ComponentGetter;
import de.uhd.ifi.se.decision.documentation.jira.mocks.MockDefaultUserManager;


public class TestComponentGetter {

private ComponentGetter getter;

private PluginSettingsFactory factory;
private TransactionTemplate transactionTemplate;
private IssueService issueService;
private ProjectService projectService;
private SearchService searchService;
private UserManager userManager;
private TemplateRenderer templateRenderer;
private ActiveObjects ao;
private SearchService searchService;
private UserManager userManager;
private TemplateRenderer templateRenderer;
private ActiveObjects ao;

@Before
public void setUp() {
factory = mock(PluginSettingsFactory.class);
transactionTemplate = mock(TransactionTemplate.class);
issueService = mock(IssueService.class);
projectService = mock(ProjectService.class);
searchService= mock(SearchService.class);
searchService = mock(SearchService.class);
userManager = new MockDefaultUserManager();
templateRenderer = mock(TemplateRenderer.class);
ao = mock(ActiveObjects.class);

getter= new ComponentGetter(factory, transactionTemplate,
issueService, projectService, searchService, userManager, templateRenderer, ao);
new ComponentGetter(factory, transactionTemplate, issueService, projectService, searchService, userManager,
templateRenderer, ao);
}

@Test
Expand Down Expand Up @@ -89,7 +86,7 @@ public void testGetActivObjects() {

@Test
public void testGetPluginStorageKey() {
assertEquals("de.uhd.ifi.se.decision.documentation.jira",ComponentGetter.getPluginStorageKey());
assertEquals("de.uhd.ifi.se.decision.documentation.jira", ComponentGetter.getPluginStorageKey());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import java.util.ArrayList;

import com.atlassian.jira.bc.issue.IssueService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.config.ConstantsManager;
import com.atlassian.jira.exception.CreateException;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.issuetype.IssueType;
Expand Down Expand Up @@ -52,9 +50,9 @@ public void initialization() {

new MockComponentWorker().init().addMock(IssueManager.class, issueManager)
.addMock(IssueLinkManager.class, new MockIssueLinkManager())
.addMock(IssueLinkTypeManager.class, new MockIssueLinkTypeManager()).addMock(IssueService.class, issueService)
.addMock(ProjectManager.class, projectManager).addMock(UserManager.class, userManager)
.addMock(ConstantsManager.class, constantsManager);
.addMock(IssueLinkTypeManager.class, new MockIssueLinkTypeManager())
.addMock(IssueService.class, issueService).addMock(ProjectManager.class, projectManager)
.addMock(UserManager.class, userManager).addMock(ConstantsManager.class, constantsManager);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,29 @@
@RunWith(ActiveObjectsJUnitRunner.class)
public class TestProjects extends TestSetUp {

private EntityManager entityManager;
private ProjectManager projectManager;


private Projects projects;

@Before
public void setUp(){
projectManager = new MockProjectManager();
new MockComponentWorker().init().addMock(ProjectManager.class, projectManager);
new ComponentGetter().init(new TestActiveObjects(entityManager), new MockTransactionTemplate(), new MockDefaultUserManager());
projects = new Projects();
}

@Test
public void testGetProjectMapNoProject(){
Map<String, DecisionKnowledgeProject> map = new HashMap<String, DecisionKnowledgeProject>();
assertEquals(map, this.projects.getProjectsMap());
}

@Test
public void testGetProjectMapProjects(){
Project project = new MockProject(1, "TEST");
((MockProject) project).setKey("TEST");
((MockProjectManager) projectManager).addProject(project);
assertTrue(this.projects.getProjectsMap().size()>=0);
}
private EntityManager entityManager;
private ProjectManager projectManager;

@Before
public void setUp() {
projectManager = new MockProjectManager();
new MockComponentWorker().init().addMock(ProjectManager.class, projectManager);
new ComponentGetter().init(new TestActiveObjects(entityManager), new MockTransactionTemplate(),
new MockDefaultUserManager());
new Projects();
}

@Test
public void testGetProjectMapNoProject() {
Map<String, DecisionKnowledgeProject> map = new HashMap<String, DecisionKnowledgeProject>();
assertEquals(map, Projects.getProjectsMap());
}

@Test
public void testGetProjectMapProjects() {
Project project = new MockProject(1, "TEST");
((MockProject) project).setKey("TEST");
((MockProjectManager) projectManager).addProject(project);
assertTrue(Projects.getProjectsMap().size() >= 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
import java.util.Collection;
import java.util.List;

import de.uhd.ifi.se.decision.documentation.jira.model.KnowledgeType;
import de.uhd.ifi.se.decision.documentation.jira.model.LinkImpl;
import de.uhd.ifi.se.decision.documentation.jira.persistence.PersistenceStrategy;
import de.uhd.ifi.se.decision.documentation.jira.persistence.StrategyProvider;
import org.ofbiz.core.entity.GenericValue;

import com.atlassian.jira.exception.CreateException;
Expand All @@ -17,6 +13,9 @@
import com.atlassian.jira.issue.link.IssueLinkType;
import com.atlassian.jira.issue.link.LinkCollection;
import com.atlassian.jira.user.ApplicationUser;

import de.uhd.ifi.se.decision.documentation.jira.model.KnowledgeType;

/**
*
* @author Tim Kuchenbuch
Expand All @@ -33,30 +32,30 @@ public void changeIssueLinkType(IssueLink arg0, IssueLinkType arg1, ApplicationU
@Override
public void createIssueLink(Long arg0, Long arg1, Long arg2, Long arg3, ApplicationUser arg4)
throws CreateException {
if(arg0==4) {
if (arg0 == 4) {
return;
}
if(arg4==null) {
if (arg4 == null) {
throw new NullPointerException();
}
if(arg4.getUsername().equals("CreateExecption")) {
if (arg4.getUsername().equals("CreateExecption")) {
throw new CreateException();
}
}

@Override
public List<IssueLink> getInwardLinks(Long arg0) {
List<IssueLink> allInwardIssueLink = new ArrayList<>();
if(arg0==20) {
IssueLink link = new MockIssueLink((long)3);
if (arg0 == 20) {
IssueLink link = new MockIssueLink((long) 3);
allInwardIssueLink.add(link);
}
if(arg0==30) {
for(int i=0 ;i<10;i++) {
IssueLink link = new MockIssueLink((long)3);
((MockIssueLink)link).setSequence((long)i);
if(i==9) {
((MockIssueLink)link).setSequence((long)1);
if (arg0 == 30) {
for (int i = 0; i < 10; i++) {
IssueLink link = new MockIssueLink((long) 3);
((MockIssueLink) link).setSequence((long) i);
if (i == 9) {
((MockIssueLink) link).setSequence((long) 1);
}
allInwardIssueLink.add(link);
}
Expand All @@ -72,7 +71,7 @@ public IssueLink getIssueLink(Long arg0) {

@Override
public IssueLink getIssueLink(Long arg0, Long arg1, Long arg2) {
if(arg1 == 1) {
if (arg1 == 1) {
IssueLink issueLink = new MockIssueLink(arg0);
return issueLink;
}
Expand Down Expand Up @@ -107,30 +106,28 @@ public LinkCollection getLinkCollectionOverrideSecurity(Issue arg0) {
@Override
public List<IssueLink> getOutwardLinks(Long arg0) {
List<IssueLink> allOutwardIssueLink = new ArrayList<>();
if(arg0.intValue() == 5000){
long i = 2;
for(KnowledgeType type : KnowledgeType.values()){
if (arg0.intValue() == 5000) {
for (long i = 2; i <= KnowledgeType.values().length; i++) {
MockIssueLink link = new MockIssueLink(i);
allOutwardIssueLink.add(link);
i++;
}
}
if(arg0 == 20) {
IssueLink link = new MockIssueLink((long)4);
if (arg0 == 20) {
IssueLink link = new MockIssueLink((long) 4);
allOutwardIssueLink.add(link);
}
if(arg0 == 30) {
for(int i=0 ;i<10;i++) {
IssueLink link = new MockIssueLink((long)3);
((MockIssueLink)link).setSequence((long)i+10);
if(i==9) {
((MockIssueLink)link).setSequence((long)1);
if (arg0 == 30) {
for (int i = 0; i < 10; i++) {
IssueLink link = new MockIssueLink((long) 3);
((MockIssueLink) link).setSequence((long) i + 10);
if (i == 9) {
((MockIssueLink) link).setSequence((long) 1);
}
allOutwardIssueLink.add(link);
}
}
if(arg0 == 12) {
MockIssueLink link = new MockIssueLink((long)1);
if (arg0 == 12) {
MockIssueLink link = new MockIssueLink((long) 1);
allOutwardIssueLink.add(link);
}
return allOutwardIssueLink;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,64 +1,61 @@
package de.uhd.ifi.se.decision.documentation.jira.model;

import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.util.ArrayList;

import static org.junit.Assert.*;
import org.junit.Test;

public class TestKnowledgeType {
private KnowledgeType knowledgeType;

@Test
public void testGetKnowledgeTypeNull(){
assertEquals(KnowledgeType.OTHER,KnowledgeType.getKnowledgeType(null));
}

@Test
public void testGetKnowledgeTypeNotExistend(){
assertEquals(KnowledgeType.OTHER,KnowledgeType.getKnowledgeType("Test"));
}

@Test
public void testGetKnowledgeTypeExistend(){
for(KnowledgeType type :KnowledgeType.values()){
assertEquals(type, KnowledgeType.getKnowledgeType(type.toString()));
}

}

@Test
public void testGetSuperTypeNull(){
assertNull(KnowledgeType.getSuperType(null));
}

@Test
public void testGetSuperTypeNotCovered(){
assertEquals(KnowledgeType.CONTEXT, KnowledgeType.getSuperType(KnowledgeType.CONTEXT));
}

@Test
public void testGetSuperTypeCovered(){
assertEquals(KnowledgeType.PROBLEM, KnowledgeType.getSuperType(KnowledgeType.ISSUE));
assertEquals(KnowledgeType.PROBLEM, KnowledgeType.getSuperType(KnowledgeType.GOAL));
assertEquals(KnowledgeType.SOLUTION, KnowledgeType.getSuperType(KnowledgeType.ALTERNATIVE));
assertEquals(KnowledgeType.SOLUTION, KnowledgeType.getSuperType(KnowledgeType.CLAIM));
assertEquals(KnowledgeType.CONTEXT, KnowledgeType.getSuperType(KnowledgeType.CONSTRAINT));
assertEquals(KnowledgeType.CONTEXT, KnowledgeType.getSuperType(KnowledgeType.ASSUMPTION));
assertEquals(KnowledgeType.CONTEXT, KnowledgeType.getSuperType(KnowledgeType.IMPLICATION));
assertEquals(KnowledgeType.RATIONALE, KnowledgeType.getSuperType(KnowledgeType.ARGUMENT));
assertEquals(KnowledgeType.RATIONALE, KnowledgeType.getSuperType(KnowledgeType.ASSESSMENT));
assertEquals(KnowledgeType.PROBLEM, KnowledgeType.ISSUE.getSuperType());
}

@Test
public void testToString(){
assertEquals("Issue", KnowledgeType.ISSUE.toString());
}

@Test
public void testToList(){
assertEquals(ArrayList.class, KnowledgeType.toList().getClass());
}
@Test
public void testGetKnowledgeTypeNull() {
assertEquals(KnowledgeType.OTHER, KnowledgeType.getKnowledgeType(null));
}

@Test
public void testGetKnowledgeTypeNotExistend() {
assertEquals(KnowledgeType.OTHER, KnowledgeType.getKnowledgeType("Test"));
}

@Test
public void testGetKnowledgeTypeExistend() {
for (KnowledgeType type : KnowledgeType.values()) {
assertEquals(type, KnowledgeType.getKnowledgeType(type.toString()));
}
}

@Test
public void testGetSuperTypeNull() {
assertNull(KnowledgeType.getSuperType(null));
}

@Test
public void testGetSuperTypeNotCovered() {
assertEquals(KnowledgeType.CONTEXT, KnowledgeType.getSuperType(KnowledgeType.CONTEXT));
}

@Test
public void testGetSuperTypeCovered() {
assertEquals(KnowledgeType.PROBLEM, KnowledgeType.getSuperType(KnowledgeType.ISSUE));
assertEquals(KnowledgeType.PROBLEM, KnowledgeType.getSuperType(KnowledgeType.GOAL));
assertEquals(KnowledgeType.SOLUTION, KnowledgeType.getSuperType(KnowledgeType.ALTERNATIVE));
assertEquals(KnowledgeType.SOLUTION, KnowledgeType.getSuperType(KnowledgeType.CLAIM));
assertEquals(KnowledgeType.CONTEXT, KnowledgeType.getSuperType(KnowledgeType.CONSTRAINT));
assertEquals(KnowledgeType.CONTEXT, KnowledgeType.getSuperType(KnowledgeType.ASSUMPTION));
assertEquals(KnowledgeType.CONTEXT, KnowledgeType.getSuperType(KnowledgeType.IMPLICATION));
assertEquals(KnowledgeType.RATIONALE, KnowledgeType.getSuperType(KnowledgeType.ARGUMENT));
assertEquals(KnowledgeType.RATIONALE, KnowledgeType.getSuperType(KnowledgeType.ASSESSMENT));
assertEquals(KnowledgeType.PROBLEM, KnowledgeType.ISSUE.getSuperType());
}

@Test
public void testToString() {
assertEquals("Issue", KnowledgeType.ISSUE.toString());
}

@Test
public void testToList() {
assertEquals(ArrayList.class, KnowledgeType.toList().getClass());
}
}
Loading

0 comments on commit 40dde79

Please sign in to comment.