TSK-343 Using Bean Utils for mappers with tests
This commit is contained in:
parent
bc83b1c500
commit
ecd5bd86a3
12
rest/pom.xml
12
rest/pom.xml
|
@ -60,6 +60,18 @@
|
|||
<artifactId>spring-hateoas</artifactId>
|
||||
<version>0.24.0.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -10,7 +10,7 @@ public class ClassificationResource extends ResourceSupport {
|
|||
public String category;
|
||||
public String type;
|
||||
public String domain;
|
||||
public boolean isValidInDomain;
|
||||
public Boolean isValidInDomain;
|
||||
public String created; // ISO-8601
|
||||
public String name;
|
||||
public String description;
|
||||
|
@ -26,37 +26,171 @@ public class ClassificationResource extends ResourceSupport {
|
|||
public String custom7;
|
||||
public String custom8;
|
||||
|
||||
public ClassificationResource() {
|
||||
// necessary for deserializing
|
||||
public void setIsValidInDomain(Boolean validInDomain) {
|
||||
isValidInDomain = validInDomain;
|
||||
}
|
||||
|
||||
public ClassificationResource(String classificationId, String key, String parentId, String category, String type,
|
||||
String domain,
|
||||
boolean isValidInDomain, String created, String name, String description,
|
||||
int priority, String serviceLevel, String applicationEntryPoint, String custom1,
|
||||
String custom2, String custom3, String custom4, String custom5, String custom6,
|
||||
String custom7, String custom8) {
|
||||
super();
|
||||
public String getClassificationId() {
|
||||
return classificationId;
|
||||
}
|
||||
|
||||
public void setClassificationId(String classificationId) {
|
||||
this.classificationId = classificationId;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getParentId() {
|
||||
return parentId;
|
||||
}
|
||||
|
||||
public void setParentId(String parentId) {
|
||||
this.parentId = parentId;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
this.isValidInDomain = isValidInDomain;
|
||||
}
|
||||
|
||||
public boolean isValidInDomain() {
|
||||
return isValidInDomain;
|
||||
}
|
||||
|
||||
public String getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(String created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public String getServiceLevel() {
|
||||
return serviceLevel;
|
||||
}
|
||||
|
||||
public void setServiceLevel(String serviceLevel) {
|
||||
this.serviceLevel = serviceLevel;
|
||||
}
|
||||
|
||||
public String getApplicationEntryPoint() {
|
||||
return applicationEntryPoint;
|
||||
}
|
||||
|
||||
public void setApplicationEntryPoint(String applicationEntryPoint) {
|
||||
this.applicationEntryPoint = applicationEntryPoint;
|
||||
}
|
||||
|
||||
public String getCustom1() {
|
||||
return custom1;
|
||||
}
|
||||
|
||||
public void setCustom1(String custom1) {
|
||||
this.custom1 = custom1;
|
||||
}
|
||||
|
||||
public String getCustom2() {
|
||||
return custom2;
|
||||
}
|
||||
|
||||
public void setCustom2(String custom2) {
|
||||
this.custom2 = custom2;
|
||||
}
|
||||
|
||||
public String getCustom3() {
|
||||
return custom3;
|
||||
}
|
||||
|
||||
public void setCustom3(String custom3) {
|
||||
this.custom3 = custom3;
|
||||
}
|
||||
|
||||
public String getCustom4() {
|
||||
return custom4;
|
||||
}
|
||||
|
||||
public void setCustom4(String custom4) {
|
||||
this.custom4 = custom4;
|
||||
}
|
||||
|
||||
public String getCustom5() {
|
||||
return custom5;
|
||||
}
|
||||
|
||||
public void setCustom5(String custom5) {
|
||||
this.custom5 = custom5;
|
||||
}
|
||||
|
||||
public String getCustom6() {
|
||||
return custom6;
|
||||
}
|
||||
|
||||
public void setCustom6(String custom6) {
|
||||
this.custom6 = custom6;
|
||||
}
|
||||
|
||||
public String getCustom7() {
|
||||
return custom7;
|
||||
}
|
||||
|
||||
public void setCustom7(String custom7) {
|
||||
this.custom7 = custom7;
|
||||
}
|
||||
|
||||
public String getCustom8() {
|
||||
return custom8;
|
||||
}
|
||||
|
||||
public void setCustom8(String custom8) {
|
||||
this.custom8 = custom8;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,34 +32,163 @@ public class WorkbasketAccessItemResource extends ResourceSupport {
|
|||
public boolean permCustom11;
|
||||
public boolean permCustom12;
|
||||
|
||||
public WorkbasketAccessItemResource() {
|
||||
public String getAccessItemId() {
|
||||
return accessItemId;
|
||||
}
|
||||
|
||||
public WorkbasketAccessItemResource(String accessItemId, String workbasketId, String accessId, boolean permRead,
|
||||
boolean permOpen, boolean permAppend, boolean permTransfer, boolean permDistribute, boolean permCustom1,
|
||||
boolean permCustom2, boolean permCustom3, boolean permCustom4, boolean permCustom5, boolean permCustom6,
|
||||
boolean permCustom7, boolean permCustom8, boolean permCustom9, boolean permCustom10, boolean permCustom11,
|
||||
boolean permCustom12) {
|
||||
super();
|
||||
public void setAccessItemId(String accessItemId) {
|
||||
this.accessItemId = accessItemId;
|
||||
}
|
||||
|
||||
public String getWorkbasketId() {
|
||||
return workbasketId;
|
||||
}
|
||||
|
||||
public void setWorkbasketId(String workbasketId) {
|
||||
this.workbasketId = workbasketId;
|
||||
}
|
||||
|
||||
public String getAccessId() {
|
||||
return accessId;
|
||||
}
|
||||
|
||||
public void setAccessId(String accessId) {
|
||||
this.accessId = accessId;
|
||||
}
|
||||
|
||||
public boolean isPermRead() {
|
||||
return permRead;
|
||||
}
|
||||
|
||||
public void setPermRead(boolean permRead) {
|
||||
this.permRead = permRead;
|
||||
}
|
||||
|
||||
public boolean isPermOpen() {
|
||||
return permOpen;
|
||||
}
|
||||
|
||||
public void setPermOpen(boolean permOpen) {
|
||||
this.permOpen = permOpen;
|
||||
}
|
||||
|
||||
public boolean isPermAppend() {
|
||||
return permAppend;
|
||||
}
|
||||
|
||||
public void setPermAppend(boolean permAppend) {
|
||||
this.permAppend = permAppend;
|
||||
}
|
||||
|
||||
public boolean isPermTransfer() {
|
||||
return permTransfer;
|
||||
}
|
||||
|
||||
public void setPermTransfer(boolean permTransfer) {
|
||||
this.permTransfer = permTransfer;
|
||||
}
|
||||
|
||||
public boolean isPermDistribute() {
|
||||
return permDistribute;
|
||||
}
|
||||
|
||||
public void setPermDistribute(boolean permDistribute) {
|
||||
this.permDistribute = permDistribute;
|
||||
}
|
||||
|
||||
public boolean isPermCustom1() {
|
||||
return permCustom1;
|
||||
}
|
||||
|
||||
public void setPermCustom1(boolean permCustom1) {
|
||||
this.permCustom1 = permCustom1;
|
||||
}
|
||||
|
||||
public boolean isPermCustom2() {
|
||||
return permCustom2;
|
||||
}
|
||||
|
||||
public void setPermCustom2(boolean permCustom2) {
|
||||
this.permCustom2 = permCustom2;
|
||||
}
|
||||
|
||||
public boolean isPermCustom3() {
|
||||
return permCustom3;
|
||||
}
|
||||
|
||||
public void setPermCustom3(boolean permCustom3) {
|
||||
this.permCustom3 = permCustom3;
|
||||
}
|
||||
|
||||
public boolean isPermCustom4() {
|
||||
return permCustom4;
|
||||
}
|
||||
|
||||
public void setPermCustom4(boolean permCustom4) {
|
||||
this.permCustom4 = permCustom4;
|
||||
}
|
||||
|
||||
public boolean isPermCustom5() {
|
||||
return permCustom5;
|
||||
}
|
||||
|
||||
public void setPermCustom5(boolean permCustom5) {
|
||||
this.permCustom5 = permCustom5;
|
||||
}
|
||||
|
||||
public boolean isPermCustom6() {
|
||||
return permCustom6;
|
||||
}
|
||||
|
||||
public void setPermCustom6(boolean permCustom6) {
|
||||
this.permCustom6 = permCustom6;
|
||||
}
|
||||
|
||||
public boolean isPermCustom7() {
|
||||
return permCustom7;
|
||||
}
|
||||
|
||||
public void setPermCustom7(boolean permCustom7) {
|
||||
this.permCustom7 = permCustom7;
|
||||
}
|
||||
|
||||
public boolean isPermCustom8() {
|
||||
return permCustom8;
|
||||
}
|
||||
|
||||
public void setPermCustom8(boolean permCustom8) {
|
||||
this.permCustom8 = permCustom8;
|
||||
}
|
||||
|
||||
public boolean isPermCustom9() {
|
||||
return permCustom9;
|
||||
}
|
||||
|
||||
public void setPermCustom9(boolean permCustom9) {
|
||||
this.permCustom9 = permCustom9;
|
||||
}
|
||||
|
||||
public boolean isPermCustom10() {
|
||||
return permCustom10;
|
||||
}
|
||||
|
||||
public void setPermCustom10(boolean permCustom10) {
|
||||
this.permCustom10 = permCustom10;
|
||||
}
|
||||
|
||||
public boolean isPermCustom11() {
|
||||
return permCustom11;
|
||||
}
|
||||
|
||||
public void setPermCustom11(boolean permCustom11) {
|
||||
this.permCustom11 = permCustom11;
|
||||
}
|
||||
|
||||
public boolean isPermCustom12() {
|
||||
return permCustom12;
|
||||
}
|
||||
|
||||
public void setPermCustom12(boolean permCustom12) {
|
||||
this.permCustom12 = permCustom12;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,31 +35,139 @@ public class WorkbasketResource extends ResourceSupport {
|
|||
public String orgLevel3;
|
||||
public String orgLevel4;
|
||||
|
||||
public WorkbasketResource() {
|
||||
//necessary for de-serializing
|
||||
public String getWorkbasketId() {
|
||||
return workbasketId;
|
||||
}
|
||||
|
||||
public WorkbasketResource(String workbasketId, String key, String name, String domain, WorkbasketType type,
|
||||
String created,
|
||||
String modified, String description, String owner, String custom1, String custom2, String custom3,
|
||||
String custom4, String orgLevel1, String orgLevel2, String orgLevel3, String orgLevel4) {
|
||||
super();
|
||||
public void setWorkbasketId(String workbasketId) {
|
||||
this.workbasketId = workbasketId;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public WorkbasketType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WorkbasketType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(String created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void setModified(String modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getCustom1() {
|
||||
return custom1;
|
||||
}
|
||||
|
||||
public void setCustom1(String custom1) {
|
||||
this.custom1 = custom1;
|
||||
}
|
||||
|
||||
public String getCustom2() {
|
||||
return custom2;
|
||||
}
|
||||
|
||||
public void setCustom2(String custom2) {
|
||||
this.custom2 = custom2;
|
||||
}
|
||||
|
||||
public String getCustom3() {
|
||||
return custom3;
|
||||
}
|
||||
|
||||
public void setCustom3(String custom3) {
|
||||
this.custom3 = custom3;
|
||||
}
|
||||
|
||||
public String getCustom4() {
|
||||
return custom4;
|
||||
}
|
||||
|
||||
public void setCustom4(String custom4) {
|
||||
this.custom4 = custom4;
|
||||
}
|
||||
|
||||
public String getOrgLevel1() {
|
||||
return orgLevel1;
|
||||
}
|
||||
|
||||
public void setOrgLevel1(String orgLevel1) {
|
||||
this.orgLevel1 = orgLevel1;
|
||||
}
|
||||
|
||||
public String getOrgLevel2() {
|
||||
return orgLevel2;
|
||||
}
|
||||
|
||||
public void setOrgLevel2(String orgLevel2) {
|
||||
this.orgLevel2 = orgLevel2;
|
||||
}
|
||||
|
||||
public String getOrgLevel3() {
|
||||
return orgLevel3;
|
||||
}
|
||||
|
||||
public void setOrgLevel3(String orgLevel3) {
|
||||
this.orgLevel3 = orgLevel3;
|
||||
}
|
||||
|
||||
public String getOrgLevel4() {
|
||||
return orgLevel4;
|
||||
}
|
||||
|
||||
public void setOrgLevel4(String orgLevel4) {
|
||||
this.orgLevel4 = orgLevel4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,22 +29,91 @@ public class WorkbasketSummaryResource extends ResourceSupport {
|
|||
public String orgLevel3;
|
||||
public String orgLevel4;
|
||||
|
||||
public WorkbasketSummaryResource() {
|
||||
public String getWorkbasketId() {
|
||||
return workbasketId;
|
||||
}
|
||||
|
||||
public WorkbasketSummaryResource(String workbasketId, String key, String name, String description, String owner,
|
||||
String domain, WorkbasketType type, String orgLevel1, String orgLevel2, String orgLevel3, String orgLevel4) {
|
||||
super();
|
||||
public void setWorkbasketId(String workbasketId) {
|
||||
this.workbasketId = workbasketId;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return domain;
|
||||
}
|
||||
|
||||
public void setDomain(String domain) {
|
||||
this.domain = domain;
|
||||
}
|
||||
|
||||
public WorkbasketType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WorkbasketType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getOrgLevel1() {
|
||||
return orgLevel1;
|
||||
}
|
||||
|
||||
public void setOrgLevel1(String orgLevel1) {
|
||||
this.orgLevel1 = orgLevel1;
|
||||
}
|
||||
|
||||
public String getOrgLevel2() {
|
||||
return orgLevel2;
|
||||
}
|
||||
|
||||
public void setOrgLevel2(String orgLevel2) {
|
||||
this.orgLevel2 = orgLevel2;
|
||||
}
|
||||
|
||||
public String getOrgLevel3() {
|
||||
return orgLevel3;
|
||||
}
|
||||
|
||||
public void setOrgLevel3(String orgLevel3) {
|
||||
this.orgLevel3 = orgLevel3;
|
||||
}
|
||||
|
||||
public String getOrgLevel4() {
|
||||
return orgLevel4;
|
||||
}
|
||||
|
||||
public void setOrgLevel4(String orgLevel4) {
|
||||
this.orgLevel4 = orgLevel4;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package pro.taskana.rest.resource.mapper;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.impl.ClassificationImpl;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
|
||||
@Component
|
||||
|
@ -13,49 +17,21 @@ public class ClassificationMapper {
|
|||
@Autowired ClassificationService classificationService;
|
||||
|
||||
public ClassificationResource toResource(Classification classification) {
|
||||
return new ClassificationResource(
|
||||
classification.getId(),
|
||||
classification.getKey(),
|
||||
classification.getParentId(),
|
||||
classification.getCategory(),
|
||||
classification.getType(),
|
||||
classification.getDomain(),
|
||||
classification.getIsValidInDomain(),
|
||||
classification.getCreated().toString(),
|
||||
classification.getName(),
|
||||
classification.getDescription(),
|
||||
classification.getPriority(),
|
||||
classification.getServiceLevel(),
|
||||
classification.getApplicationEntryPoint(),
|
||||
classification.getCustom1(),
|
||||
classification.getCustom2(),
|
||||
classification.getCustom3(),
|
||||
classification.getCustom4(),
|
||||
classification.getCustom5(),
|
||||
classification.getCustom6(),
|
||||
classification.getCustom7(),
|
||||
classification.getCustom8());
|
||||
ClassificationResource resource = new ClassificationResource();
|
||||
BeanUtils.copyProperties(classification, resource);
|
||||
//need to be set by hand, because they are named different, or have different types
|
||||
resource.setClassificationId(classification.getId());
|
||||
resource.setCreated(classification.getCreated().toString());
|
||||
return resource;
|
||||
}
|
||||
|
||||
public Classification toModel(ClassificationResource classificationResource) {
|
||||
Classification classification = classificationService.newClassification(classificationResource.domain,
|
||||
classificationResource.key, classificationResource.type);
|
||||
classification.setServiceLevel(classificationResource.serviceLevel);
|
||||
classification.setPriority(classificationResource.priority);
|
||||
classification.setParentId(classificationResource.parentId);
|
||||
classification.setName(classificationResource.name);
|
||||
classification.setIsValidInDomain(classificationResource.isValidInDomain);
|
||||
classification.setDescription(classificationResource.description);
|
||||
classification.setCustom1(classificationResource.custom1);
|
||||
classification.setCustom2(classificationResource.custom2);
|
||||
classification.setCustom3(classificationResource.custom3);
|
||||
classification.setCustom4(classificationResource.custom4);
|
||||
classification.setCustom5(classificationResource.custom5);
|
||||
classification.setCustom6(classificationResource.custom6);
|
||||
classification.setCustom7(classificationResource.custom7);
|
||||
classification.setCustom8(classificationResource.custom8);
|
||||
classification.setCategory(classificationResource.category);
|
||||
classification.setApplicationEntryPoint(classificationResource.applicationEntryPoint);
|
||||
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification(
|
||||
classificationResource.domain, classificationResource.key, classificationResource.type);
|
||||
BeanUtils.copyProperties(classificationResource, classification);
|
||||
|
||||
classification.setId(classificationResource.getClassificationId());
|
||||
classification.setCreated(Instant.parse(classificationResource.getCreated()));
|
||||
return classification;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package pro.taskana.rest.resource.mapper;
|
|||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -19,15 +20,10 @@ public class WorkbasketAccessItemMapper {
|
|||
private WorkbasketService workbasketService;
|
||||
|
||||
public WorkbasketAccessItemResource toResource(WorkbasketAccessItem wbAccItem) {
|
||||
WorkbasketAccessItemResource resource = new WorkbasketAccessItemResource(wbAccItem.getId(),
|
||||
wbAccItem.getWorkbasketId(),
|
||||
wbAccItem.getAccessId(), wbAccItem.isPermRead(), wbAccItem.isPermOpen(), wbAccItem.isPermAppend(),
|
||||
wbAccItem.isPermTransfer(),
|
||||
wbAccItem.isPermDistribute(), wbAccItem.isPermCustom1(), wbAccItem.isPermCustom2(),
|
||||
wbAccItem.isPermCustom3(), wbAccItem.isPermCustom4(),
|
||||
wbAccItem.isPermCustom5(), wbAccItem.isPermCustom6(), wbAccItem.isPermCustom7(), wbAccItem.isPermCustom8(),
|
||||
wbAccItem.isPermCustom9(),
|
||||
wbAccItem.isPermCustom10(), wbAccItem.isPermCustom11(), wbAccItem.isPermCustom12());
|
||||
WorkbasketAccessItemResource resource = new WorkbasketAccessItemResource();
|
||||
BeanUtils.copyProperties(wbAccItem, resource);
|
||||
//property is named different, so it needs to be set by hand
|
||||
resource.setAccessItemId(wbAccItem.getId());
|
||||
|
||||
// Add self-decription link to hateoas
|
||||
resource.add(
|
||||
|
@ -37,27 +33,12 @@ public class WorkbasketAccessItemMapper {
|
|||
}
|
||||
|
||||
public WorkbasketAccessItem toModel(WorkbasketAccessItemResource wbAccItemRecource) {
|
||||
WorkbasketAccessItemImpl wbAccItemModel = (WorkbasketAccessItemImpl) workbasketService
|
||||
.newWorkbasketAccessItem(wbAccItemRecource.workbasketId, wbAccItemRecource.accessId);
|
||||
WorkbasketAccessItemImpl wbAccItemModel = (WorkbasketAccessItemImpl) workbasketService.newWorkbasketAccessItem(
|
||||
wbAccItemRecource.workbasketId, wbAccItemRecource.accessId);
|
||||
BeanUtils.copyProperties(wbAccItemRecource, wbAccItemModel);
|
||||
|
||||
wbAccItemModel.setId(wbAccItemRecource.accessItemId);
|
||||
wbAccItemModel.setPermRead(wbAccItemRecource.permRead);
|
||||
wbAccItemModel.setPermOpen(wbAccItemRecource.permOpen);
|
||||
wbAccItemModel.setPermAppend(wbAccItemRecource.permAppend);
|
||||
wbAccItemModel.setPermTransfer(wbAccItemRecource.permTransfer);
|
||||
wbAccItemModel.setPermDistribute(wbAccItemRecource.permDistribute);
|
||||
wbAccItemModel.setPermCustom1(wbAccItemRecource.permCustom1);
|
||||
wbAccItemModel.setPermCustom2(wbAccItemRecource.permCustom2);
|
||||
wbAccItemModel.setPermCustom3(wbAccItemRecource.permCustom3);
|
||||
wbAccItemModel.setPermCustom4(wbAccItemRecource.permCustom4);
|
||||
wbAccItemModel.setPermCustom5(wbAccItemRecource.permCustom5);
|
||||
wbAccItemModel.setPermCustom6(wbAccItemRecource.permCustom6);
|
||||
wbAccItemModel.setPermCustom7(wbAccItemRecource.permCustom7);
|
||||
wbAccItemModel.setPermCustom8(wbAccItemRecource.permCustom8);
|
||||
wbAccItemModel.setPermCustom9(wbAccItemRecource.permCustom9);
|
||||
wbAccItemModel.setPermCustom10(wbAccItemRecource.permCustom10);
|
||||
wbAccItemModel.setPermCustom11(wbAccItemRecource.permCustom11);
|
||||
wbAccItemModel.setPermCustom12(wbAccItemRecource.permCustom12);
|
||||
return wbAccItemModel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
|||
|
||||
import java.time.Instant;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -21,12 +22,12 @@ public class WorkbasketMapper {
|
|||
private WorkbasketService workbasketService;
|
||||
|
||||
public WorkbasketResource toResource(Workbasket wb) {
|
||||
WorkbasketResource resource = new WorkbasketResource(wb.getId(), wb.getKey(), wb.getName(), wb.getDomain(),
|
||||
wb.getType(), wb.getCreated().toString(), wb.getModified().toString(), wb.getDescription(), wb.getOwner(),
|
||||
wb.getCustom1(),
|
||||
wb.getCustom2(), wb.getCustom3(),
|
||||
wb.getCustom4(),
|
||||
wb.getOrgLevel1(), wb.getOrgLevel2(), wb.getOrgLevel3(), wb.getOrgLevel4());
|
||||
WorkbasketResource resource = new WorkbasketResource();
|
||||
BeanUtils.copyProperties(wb, resource);
|
||||
//need to be set by hand, since name or type is different
|
||||
resource.setWorkbasketId(wb.getId());
|
||||
resource.setModified(wb.getModified().toString());
|
||||
resource.setCreated(wb.getCreated().toString());
|
||||
|
||||
// Add self-decription link to hateoas
|
||||
resource.add(linkTo(methodOn(WorkbasketController.class).getWorkbasket(wb.getId())).withSelfRel());
|
||||
|
@ -34,22 +35,12 @@ public class WorkbasketMapper {
|
|||
}
|
||||
|
||||
public Workbasket toModel(WorkbasketResource wbResource) {
|
||||
WorkbasketImpl wbModel = (WorkbasketImpl) workbasketService.newWorkbasket(wbResource.key, wbResource.domain);
|
||||
wbModel.setId(wbResource.workbasketId);
|
||||
wbModel.setName(wbResource.name);
|
||||
wbModel.setType(wbResource.type);
|
||||
wbModel.setCreated(Instant.parse(wbResource.created));
|
||||
wbModel.setModified(Instant.parse(wbResource.modified));
|
||||
wbModel.setDescription(wbResource.description);
|
||||
wbModel.setOwner(wbResource.owner);
|
||||
wbModel.setCustom1(wbResource.custom1);
|
||||
wbModel.setCustom2(wbResource.custom2);
|
||||
wbModel.setCustom3(wbResource.custom3);
|
||||
wbModel.setCustom4(wbResource.custom4);
|
||||
wbModel.setOrgLevel1(wbResource.orgLevel1);
|
||||
wbModel.setOrgLevel2(wbResource.orgLevel2);
|
||||
wbModel.setOrgLevel3(wbResource.orgLevel3);
|
||||
wbModel.setOrgLevel4(wbResource.orgLevel4);
|
||||
return wbModel;
|
||||
WorkbasketImpl workbasket = (WorkbasketImpl) workbasketService.newWorkbasket(wbResource.key, wbResource.domain);
|
||||
BeanUtils.copyProperties(wbResource, workbasket);
|
||||
|
||||
workbasket.setId(wbResource.workbasketId);
|
||||
workbasket.setModified(Instant.parse(wbResource.modified));
|
||||
workbasket.setCreated(Instant.parse(wbResource.created));
|
||||
return workbasket;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package pro.taskana.rest.resource.mapper;
|
|||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
|
||||
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
|
@ -13,14 +14,13 @@ import pro.taskana.rest.resource.WorkbasketSummaryResource;
|
|||
public class WorkbasketSummaryMapper {
|
||||
|
||||
public WorkbasketSummaryResource toResource(WorkbasketSummary summary) {
|
||||
WorkbasketSummaryResource resource = new WorkbasketSummaryResource(
|
||||
summary.getId(), summary.getKey(), summary.getName(), summary.getDescription(), summary.getOwner(),
|
||||
summary.getDomain(), summary.getType(), summary.getOrgLevel1(), summary.getOrgLevel2(),
|
||||
summary.getOrgLevel3(), summary.getOrgLevel4());
|
||||
WorkbasketSummaryResource resource = new WorkbasketSummaryResource();
|
||||
BeanUtils.copyProperties(summary, resource);
|
||||
//named different so needs to be set by hand
|
||||
resource.setWorkbasketId(summary.getId());
|
||||
|
||||
// Add self reference
|
||||
resource.add(linkTo(methodOn(WorkbasketController.class).getWorkbasket(summary.getId())).withSelfRel());
|
||||
|
||||
return resource;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,110 @@
|
|||
package pro.taskana.rest.resource.mapper;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.Classification;
|
||||
import pro.taskana.ClassificationService;
|
||||
import pro.taskana.impl.ClassificationImpl;
|
||||
import pro.taskana.rest.RestApplication;
|
||||
import pro.taskana.rest.resource.ClassificationResource;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {RestApplication.class})
|
||||
@WebAppConfiguration
|
||||
public class ClassificationMapperTest {
|
||||
|
||||
@Autowired ClassificationMapper classificationMapper;
|
||||
@Autowired ClassificationService classificationService;
|
||||
|
||||
@Test
|
||||
public void classificationToResource() {
|
||||
//given
|
||||
ClassificationImpl classification = (ClassificationImpl) classificationService.newClassification("DOMAIN_A",
|
||||
"1", "A");
|
||||
classification.setId("1");
|
||||
classification.setCategory("ABC");
|
||||
classification.setName("Classification 1");
|
||||
classification.setIsValidInDomain(false);
|
||||
classification.setCustom1("Custom1");
|
||||
classification.setCustom2("Custom2");
|
||||
classification.setCustom3("Custom3");
|
||||
classification.setCustom4("Custom4");
|
||||
classification.setCustom5("Custom5");
|
||||
classification.setCustom6("Custom6");
|
||||
classification.setCustom7("Custom7");
|
||||
classification.setCustom8("Custom8");
|
||||
classification.setParentId("2");
|
||||
classification.setPriority(2);
|
||||
classification.setApplicationEntryPoint("12");
|
||||
classification.setServiceLevel("P1D");
|
||||
classification.setDescription("Test");
|
||||
classification.setCreated(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
//when
|
||||
ClassificationResource classificationResource = classificationMapper.toResource(classification);
|
||||
//then
|
||||
testEquality(classification, classificationResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceToClassification() {
|
||||
//given
|
||||
ClassificationResource classificationResource = new ClassificationResource();
|
||||
classificationResource.setClassificationId("1");
|
||||
classificationResource.setKey("12");
|
||||
classificationResource.setName("TestB");
|
||||
classificationResource.setType("AB");
|
||||
classificationResource.setDomain("DOMAIN_B");
|
||||
classificationResource.setApplicationEntryPoint("Test");
|
||||
classificationResource.setCategory("ABC");
|
||||
classificationResource.setCreated("2010-01-01T12:00:00Z");
|
||||
classificationResource.setCustom1("Custom");
|
||||
classificationResource.setCustom2("Custom2");
|
||||
classificationResource.setCustom1("Custom1");
|
||||
classificationResource.setCustom3("Custom3");
|
||||
classificationResource.setCustom4("Custom4");
|
||||
classificationResource.setCustom5("Custom5");
|
||||
classificationResource.setCustom6("Custom6");
|
||||
classificationResource.setCustom7("Custom7");
|
||||
classificationResource.setCustom8("Custom8");
|
||||
classificationResource.setParentId("2");
|
||||
classificationResource.setPriority(2);
|
||||
classificationResource.setApplicationEntryPoint("12");
|
||||
classificationResource.setServiceLevel("P1D");
|
||||
classificationResource.setDescription("Test");
|
||||
//when
|
||||
ClassificationImpl classification = (ClassificationImpl) classificationMapper.toModel(classificationResource);
|
||||
//then
|
||||
testEquality(classification, classificationResource);
|
||||
}
|
||||
|
||||
private void testEquality(Classification classification, ClassificationResource classificationResource) {
|
||||
Assert.assertEquals(classification.getApplicationEntryPoint(), classificationResource.applicationEntryPoint);
|
||||
Assert.assertEquals(classification.getKey(), classificationResource.key);
|
||||
Assert.assertEquals(classification.getDomain(), classificationResource.domain);
|
||||
Assert.assertEquals(classification.getId(), classificationResource.classificationId);
|
||||
Assert.assertEquals(classification.getDescription(), classificationResource.description);
|
||||
Assert.assertEquals(classification.getName(), classificationResource.name);
|
||||
Assert.assertEquals(classification.getServiceLevel(), classificationResource.serviceLevel);
|
||||
Assert.assertEquals(classification.getCategory(), classificationResource.category);
|
||||
Assert.assertEquals(classification.getCustom1(), classificationResource.custom1);
|
||||
Assert.assertEquals(classification.getCustom2(), classificationResource.custom2);
|
||||
Assert.assertEquals(classification.getCustom3(), classificationResource.custom3);
|
||||
Assert.assertEquals(classification.getCustom4(), classificationResource.custom4);
|
||||
Assert.assertEquals(classification.getCustom5(), classificationResource.custom5);
|
||||
Assert.assertEquals(classification.getCustom6(), classificationResource.custom6);
|
||||
Assert.assertEquals(classification.getCustom7(), classificationResource.custom7);
|
||||
Assert.assertEquals(classification.getCustom8(), classificationResource.custom8);
|
||||
Assert.assertEquals(classification.getParentId(), classificationResource.parentId);
|
||||
Assert.assertEquals(classification.getType(), classificationResource.type);
|
||||
Assert.assertEquals(classification.getPriority(), classificationResource.priority);
|
||||
Assert.assertEquals(classification.getIsValidInDomain(), classificationResource.isValidInDomain);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package pro.taskana.rest.resource.mapper;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.WorkbasketAccessItem;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.rest.RestApplication;
|
||||
import pro.taskana.rest.resource.WorkbasketAccessItemResource;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {RestApplication.class})
|
||||
@WebAppConfiguration
|
||||
public class WorkbasketAccessItemMapperTest {
|
||||
|
||||
@Autowired WorkbasketAccessItemMapper workbasketAccessItemMapper;
|
||||
@Autowired WorkbasketService workbasketService;
|
||||
|
||||
@Test
|
||||
public void workBasketAccessItemToResourcePropertiesEqual() {
|
||||
//given
|
||||
WorkbasketAccessItem accessItem = workbasketService.newWorkbasketAccessItem("1", "2");
|
||||
accessItem.setPermDistribute(false);
|
||||
accessItem.setPermOpen(true);
|
||||
accessItem.setPermAppend(false);
|
||||
accessItem.setPermRead(false);
|
||||
accessItem.setPermTransfer(true);
|
||||
accessItem.setPermCustom1(false);
|
||||
accessItem.setPermCustom2(false);
|
||||
accessItem.setPermCustom3(true);
|
||||
accessItem.setPermCustom4(true);
|
||||
accessItem.setPermCustom5(true);
|
||||
accessItem.setPermCustom6(true);
|
||||
accessItem.setPermCustom7(true);
|
||||
accessItem.setPermCustom8(true);
|
||||
accessItem.setPermCustom9(true);
|
||||
accessItem.setPermCustom10(true);
|
||||
accessItem.setPermCustom11(true);
|
||||
accessItem.setPermCustom12(true);
|
||||
//when
|
||||
WorkbasketAccessItemResource resource = workbasketAccessItemMapper.toResource(
|
||||
accessItem);
|
||||
//then
|
||||
testEquality(accessItem, resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void workBasketAccessItemToModelPropertiesEqual() {
|
||||
//given
|
||||
WorkbasketAccessItemResource resource = new WorkbasketAccessItemResource();
|
||||
resource.setAccessId("10");
|
||||
resource.setAccessItemId("120");
|
||||
resource.setWorkbasketId("1");
|
||||
resource.setPermRead(true);
|
||||
resource.setPermAppend(false);
|
||||
resource.setPermDistribute(false);
|
||||
resource.setPermOpen(false);
|
||||
resource.setPermTransfer(true);
|
||||
resource.setPermCustom1(false);
|
||||
resource.setPermCustom2(false);
|
||||
resource.setPermCustom3(false);
|
||||
resource.setPermCustom4(false);
|
||||
resource.setPermCustom5(true);
|
||||
resource.setPermCustom6(false);
|
||||
resource.setPermCustom7(false);
|
||||
resource.setPermCustom8(false);
|
||||
resource.setPermCustom9(false);
|
||||
resource.setPermCustom10(false);
|
||||
resource.setPermCustom11(true);
|
||||
resource.setPermCustom12(false);
|
||||
//when
|
||||
WorkbasketAccessItem accessItem = workbasketAccessItemMapper.toModel(resource);
|
||||
//then
|
||||
testEquality(accessItem, resource);
|
||||
}
|
||||
|
||||
private void testEquality(WorkbasketAccessItem accessItem,
|
||||
WorkbasketAccessItemResource resource) {
|
||||
Assert.assertEquals(accessItem.getAccessId(), resource.accessId);
|
||||
Assert.assertEquals(accessItem.getId(), resource.accessItemId);
|
||||
Assert.assertEquals(accessItem.getWorkbasketId(), resource.workbasketId);
|
||||
Assert.assertEquals(accessItem.isPermAppend(), resource.permAppend);
|
||||
Assert.assertEquals(accessItem.isPermCustom1(), resource.permCustom1);
|
||||
Assert.assertEquals(accessItem.isPermCustom2(), resource.permCustom2);
|
||||
Assert.assertEquals(accessItem.isPermCustom3(), resource.permCustom3);
|
||||
Assert.assertEquals(accessItem.isPermCustom4(), resource.permCustom4);
|
||||
Assert.assertEquals(accessItem.isPermCustom5(), resource.permCustom5);
|
||||
Assert.assertEquals(accessItem.isPermCustom6(), resource.permCustom6);
|
||||
Assert.assertEquals(accessItem.isPermCustom7(), resource.permCustom7);
|
||||
Assert.assertEquals(accessItem.isPermCustom8(), resource.permCustom8);
|
||||
Assert.assertEquals(accessItem.isPermCustom9(), resource.permCustom9);
|
||||
Assert.assertEquals(accessItem.isPermCustom10(), resource.permCustom10);
|
||||
Assert.assertEquals(accessItem.isPermCustom11(), resource.permCustom11);
|
||||
Assert.assertEquals(accessItem.isPermCustom12(), resource.permCustom12);
|
||||
Assert.assertEquals(accessItem.isPermDistribute(), resource.permDistribute);
|
||||
Assert.assertEquals(accessItem.isPermRead(), resource.permRead);
|
||||
Assert.assertEquals(accessItem.isPermOpen(), resource.permOpen);
|
||||
Assert.assertEquals(accessItem.isPermTransfer(), resource.permTransfer);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package pro.taskana.rest.resource.mapper;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.Workbasket;
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.impl.WorkbasketImpl;
|
||||
import pro.taskana.impl.WorkbasketType;
|
||||
import pro.taskana.rest.RestApplication;
|
||||
import pro.taskana.rest.resource.WorkbasketResource;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {RestApplication.class})
|
||||
@WebAppConfiguration
|
||||
public class WorkbasketMapperTest {
|
||||
|
||||
@Autowired WorkbasketService workbasketService;
|
||||
@Autowired WorkbasketMapper workbasketMapper;
|
||||
|
||||
@Test
|
||||
public void workbasketToResource() {
|
||||
//given
|
||||
Workbasket workbasket = workbasketService.newWorkbasket("1", "DOMAIN_A");
|
||||
((WorkbasketImpl) workbasket).setId("ID");
|
||||
workbasket.setType(WorkbasketType.PERSONAL);
|
||||
workbasket.setName("Testbasket");
|
||||
workbasket.setOrgLevel1("Org1");
|
||||
workbasket.setOrgLevel2("Org2");
|
||||
workbasket.setOrgLevel3("Org3");
|
||||
workbasket.setOrgLevel4("Org4");
|
||||
workbasket.setDescription("A test workbasket");
|
||||
workbasket.setCustom1("1");
|
||||
workbasket.setCustom2("2");
|
||||
workbasket.setCustom3("3");
|
||||
workbasket.setCustom4("4");
|
||||
workbasket.setOwner("Lars");
|
||||
((WorkbasketImpl) workbasket).setCreated(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
((WorkbasketImpl) workbasket).setModified(Instant.parse("2010-01-01T12:00:00Z"));
|
||||
//when
|
||||
WorkbasketResource workbasketResource = workbasketMapper.toResource(workbasket);
|
||||
//then
|
||||
testEquality(workbasket, workbasketResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resourceToWorkbasket() {
|
||||
//given
|
||||
WorkbasketResource workbasketResource = new WorkbasketResource();
|
||||
workbasketResource.setWorkbasketId("1");
|
||||
workbasketResource.setCreated("2010-01-01T12:00:00Z");
|
||||
workbasketResource.setModified("2010-01-01T12:00:00Z");
|
||||
workbasketResource.setCustom1("Custom1");
|
||||
workbasketResource.setCustom2("Custom2");
|
||||
workbasketResource.setCustom3("Custom3");
|
||||
workbasketResource.setCustom4("Custom4");
|
||||
workbasketResource.setDescription("Test Ressource");
|
||||
workbasketResource.setDomain("DOMAIN_A");
|
||||
workbasketResource.setKey("1");
|
||||
workbasketResource.setName("Ressource");
|
||||
workbasketResource.setOrgLevel1("Org1");
|
||||
workbasketResource.setOrgLevel2("Org2");
|
||||
workbasketResource.setOrgLevel3("Org3");
|
||||
workbasketResource.setOrgLevel4("Org4");
|
||||
workbasketResource.setOwner("Lars");
|
||||
workbasketResource.setType(WorkbasketType.PERSONAL);
|
||||
//when
|
||||
Workbasket workbasket = workbasketMapper.toModel(workbasketResource);
|
||||
//then
|
||||
testEquality(workbasket, workbasketResource);
|
||||
}
|
||||
|
||||
private void testEquality(Workbasket workbasket, WorkbasketResource workbasketResource) {
|
||||
Assert.assertEquals(workbasket.getId(), workbasketResource.workbasketId);
|
||||
Assert.assertEquals(workbasket.getCustom1(), workbasketResource.custom1);
|
||||
Assert.assertEquals(workbasket.getCustom2(), workbasketResource.custom2);
|
||||
Assert.assertEquals(workbasket.getCustom3(), workbasketResource.custom3);
|
||||
Assert.assertEquals(workbasket.getCustom4(), workbasketResource.custom4);
|
||||
Assert.assertEquals(workbasket.getDescription(), workbasketResource.description);
|
||||
Assert.assertEquals(workbasket.getCreated().toString(), workbasketResource.created);
|
||||
Assert.assertEquals(workbasket.getModified().toString(), workbasketResource.modified);
|
||||
Assert.assertEquals(workbasket.getKey(), workbasketResource.key);
|
||||
Assert.assertEquals(workbasket.getDomain(), workbasketResource.domain);
|
||||
Assert.assertEquals(workbasket.getName(), workbasketResource.name);
|
||||
Assert.assertEquals(workbasket.getOrgLevel1(), workbasketResource.orgLevel1);
|
||||
Assert.assertEquals(workbasket.getOrgLevel2(), workbasketResource.orgLevel2);
|
||||
Assert.assertEquals(workbasket.getOrgLevel3(), workbasketResource.orgLevel3);
|
||||
Assert.assertEquals(workbasket.getOrgLevel4(), workbasketResource.orgLevel4);
|
||||
Assert.assertEquals(workbasket.getOwner(), workbasketResource.owner);
|
||||
Assert.assertEquals(workbasket.getType(), workbasketResource.type);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package pro.taskana.rest.resource.mapper;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
|
||||
import pro.taskana.WorkbasketService;
|
||||
import pro.taskana.WorkbasketSummary;
|
||||
import pro.taskana.impl.WorkbasketSummaryImpl;
|
||||
import pro.taskana.impl.WorkbasketType;
|
||||
import pro.taskana.rest.RestApplication;
|
||||
import pro.taskana.rest.resource.WorkbasketSummaryResource;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = {RestApplication.class})
|
||||
@WebAppConfiguration
|
||||
public class WorkbasketSummaryMapperTest {
|
||||
@Autowired WorkbasketService workbasketService;
|
||||
@Autowired WorkbasketSummaryMapper workbasketSummaryMapper;
|
||||
|
||||
@Test
|
||||
public void workbasketSummaryToResource(){
|
||||
//given
|
||||
WorkbasketSummaryImpl workbasketSummary = (WorkbasketSummaryImpl) workbasketService.newWorkbasket("1","DOMAIN_A").asSummary();
|
||||
workbasketSummary.setDescription("WorkbasketSummaryImplTes");
|
||||
workbasketSummary.setId("1");
|
||||
workbasketSummary.setName("WorkbasketSummary");
|
||||
workbasketSummary.setOrgLevel1("Org1");
|
||||
workbasketSummary.setOrgLevel2("Org2");
|
||||
workbasketSummary.setOrgLevel3("Org3");
|
||||
workbasketSummary.setOrgLevel4("Org4");
|
||||
workbasketSummary.setOwner("Lars");
|
||||
workbasketSummary.setType(WorkbasketType.PERSONAL);
|
||||
//when
|
||||
WorkbasketSummaryResource workbasketSummaryResource = workbasketSummaryMapper.toResource(workbasketSummary);
|
||||
//then
|
||||
Assert.assertEquals(workbasketSummary.getDescription(), workbasketSummaryResource.description);
|
||||
Assert.assertEquals(workbasketSummary.getDomain(), workbasketSummaryResource.domain);
|
||||
Assert.assertEquals(workbasketSummary.getId(), workbasketSummaryResource.workbasketId);
|
||||
Assert.assertEquals(workbasketSummary.getKey(), workbasketSummaryResource.key);
|
||||
Assert.assertEquals(workbasketSummary.getName(), workbasketSummaryResource.name);
|
||||
Assert.assertEquals(workbasketSummary.getOrgLevel1(), workbasketSummaryResource.orgLevel1);
|
||||
Assert.assertEquals(workbasketSummary.getOrgLevel2(), workbasketSummaryResource.orgLevel2);
|
||||
Assert.assertEquals(workbasketSummary.getOrgLevel3(), workbasketSummaryResource.orgLevel3);
|
||||
Assert.assertEquals(workbasketSummary.getOrgLevel4(), workbasketSummaryResource.orgLevel4);
|
||||
Assert.assertEquals(workbasketSummary.getOwner(), workbasketSummaryResource.owner);
|
||||
Assert.assertEquals(workbasketSummary.getType(), workbasketSummaryResource.type);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue