TSK-1106 Make ClassificationSummaryResource attributes private

TSK-1106 Converted tests to AssertJ

TSK-1106 Converted assertThrows to AssertJ

TSK-1106 Removed suppress checkstyle for lambdas
This commit is contained in:
Sofie Hofmann 2020-02-12 12:13:09 +01:00
parent a3c938d1ad
commit 01545e476e
6 changed files with 255 additions and 247 deletions

View File

@ -7,23 +7,23 @@ import pro.taskana.classification.api.ClassificationSummary;
/** Resource class for {@link ClassificationSummary}. */ /** Resource class for {@link ClassificationSummary}. */
public class ClassificationSummaryResource extends ResourceSupport { public class ClassificationSummaryResource extends ResourceSupport {
public String classificationId; private String classificationId;
public String key; private String key;
public String parentId; private String parentId;
public String parentKey; private String parentKey;
public String category; private String category;
public String type; private String type;
public String domain; private String domain;
public String name; private String name;
public int priority; private int priority;
public String custom1; private String custom1;
public String custom2; private String custom2;
public String custom3; private String custom3;
public String custom4; private String custom4;
public String custom5; private String custom5;
public String custom6; private String custom6;
public String custom7; private String custom7;
public String custom8; private String custom8;
public ClassificationSummaryResource() {} public ClassificationSummaryResource() {}

View File

@ -77,10 +77,15 @@ class ClassificationControllerIntTest {
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull(); assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
assertThat(response.getBody().getLink(Link.REL_SELF).getHref()) assertThat(
.endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc"); response
.getBody()
.getLink(Link.REL_SELF)
.getHref()
.endsWith("/api/v1/classifications?domain=DOMAIN_A&sort-by=key&order=asc"))
.isTrue();
assertThat(response.getBody().getContent()).hasSize(17); assertThat(response.getBody().getContent()).hasSize(17);
assertThat(response.getBody().getContent().iterator().next().key).isEqualTo("A12"); assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("A12");
} }
@Test @Test
@ -93,12 +98,17 @@ class ClassificationControllerIntTest {
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationSummaryListResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryListResource.class));
assertThat(response.getBody().getContent()).hasSize(5); assertThat(response.getBody().getContent()).hasSize(5);
assertThat(response.getBody().getContent().iterator().next().key).isEqualTo("L1050"); assertThat(response.getBody().getContent().iterator().next().getKey()).isEqualTo("L1050");
assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull(); assertThat(response.getBody().getLink(Link.REL_SELF)).isNotNull();
assertThat(response.getBody().getLink(Link.REL_SELF).getHref()) assertThat(
.endsWith( response
"/api/v1/classifications?" .getBody()
+ "domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5"); .getLink(Link.REL_SELF)
.getHref()
.endsWith(
"/api/v1/classifications?"
+ "domain=DOMAIN_A&sort-by=key&order=asc&page=2&page-size=5"))
.isTrue();
assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull(); assertThat(response.getBody().getLink(Link.REL_FIRST)).isNotNull();
assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull(); assertThat(response.getBody().getLink(Link.REL_LAST)).isNotNull();
assertThat(response.getBody().getLink(Link.REL_NEXT)).isNotNull(); assertThat(response.getBody().getLink(Link.REL_NEXT)).isNotNull();
@ -121,7 +131,7 @@ class ClassificationControllerIntTest {
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertThat(responseEntity).isNotNull(); assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
newClassification = newClassification =
"{\"classificationId\":\"\",\"category\":\"MANUAL\"," "{\"classificationId\":\"\",\"category\":\"MANUAL\","
@ -135,7 +145,7 @@ class ClassificationControllerIntTest {
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
} }
@Test @Test
@ -155,7 +165,7 @@ class ClassificationControllerIntTest {
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertThat(responseEntity).isNotNull(); assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
} }
@Test @Test
@ -175,7 +185,7 @@ class ClassificationControllerIntTest {
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertThat(responseEntity).isNotNull(); assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
} }
@Test @Test
@ -194,7 +204,7 @@ class ClassificationControllerIntTest {
ParameterizedTypeReference.forType(ClassificationResource.class)); ParameterizedTypeReference.forType(ClassificationResource.class));
assertThat(responseEntity).isNotNull(); assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.CREATED); assertThat(HttpStatus.CREATED).isEqualTo(responseEntity.getStatusCode());
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<ClassificationSummaryListResource> response =
template.exchange( template.exchange(
@ -209,6 +219,7 @@ class ClassificationControllerIntTest {
&& "".equals(classification.getDomain()) && "".equals(classification.getDomain())
&& "T2100".equals(classification.getParentKey())) { && "T2100".equals(classification.getParentKey())) {
foundClassificationCreated = true; foundClassificationCreated = true;
break;
} }
} }
@ -223,17 +234,17 @@ class ClassificationControllerIntTest {
+ "\"key\":\"NEW_CLASS_P3\",\"name\":\"new classification\"," + "\"key\":\"NEW_CLASS_P3\",\"name\":\"new classification\","
+ "\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\"," + "\"type\":\"TASK\",\"parentId\":\"CLI:200000000000000000000000000000000015\","
+ "\"parentKey\":\"T2000\"}"; + "\"parentKey\":\"T2000\"}";
assertThatThrownBy( assertThatThrownBy(
() -> () ->
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(newClassification, restHelper.getHeaders()), new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class))) ParameterizedTypeReference.forType(ClassificationResource.class)))
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.extracting(ex -> ((HttpClientErrorException)ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
.isEqualTo(HttpStatus.BAD_REQUEST);; .isEqualTo(HttpStatus.BAD_REQUEST);
} }
@Test @Test
@ -244,21 +255,22 @@ class ClassificationControllerIntTest {
+ "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\"," + "\"domain\":\"DOMAIN_A\",\"key\":\"NEW_CLASS\","
+ "\"name\":\"new classification\",\"type\":\"TASK\"}"; + "\"name\":\"new classification\",\"type\":\"TASK\"}";
assertThatThrownBy(() -> assertThatThrownBy(
template.exchange( () ->
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS), template.exchange(
HttpMethod.POST, restHelper.toUrl(Mapping.URL_CLASSIFICATIONS),
new HttpEntity<>(newClassification, restHelper.getHeaders()), HttpMethod.POST,
ParameterizedTypeReference.forType(ClassificationResource.class))) new HttpEntity<>(newClassification, restHelper.getHeaders()),
ParameterizedTypeReference.forType(ClassificationResource.class)))
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.extracting(ex -> ((HttpClientErrorException)ex).getStatusCode()) .extracting(ex -> ((HttpClientErrorException) ex).getStatusCode())
.isEqualTo(HttpStatus.BAD_REQUEST); .isEqualTo(HttpStatus.BAD_REQUEST);
} }
@Test @Test
void testGetClassificationWithSpecialCharacter() { void testGetClassificationWithSpecialCharacter() {
HttpEntity<String> request = new HttpEntity<String>(restHelper.getHeadersAdmin()); HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersAdmin());
ResponseEntity<ClassificationSummaryResource> response = ResponseEntity<ClassificationSummaryResource> response =
template.exchange( template.exchange(
restHelper.toUrl( restHelper.toUrl(
@ -266,13 +278,13 @@ class ClassificationControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(ClassificationSummaryResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
assertThat(response.getBody().name).isEqualTo("Zustimmungserklärung"); assertThat(response.getBody().getName()).isEqualTo("Zustimmungserklärung");
} }
@Test @Test
@DirtiesContext @DirtiesContext
void testDeleteClassification() { void testDeleteClassification() {
HttpEntity<String> request = new HttpEntity<String>(restHelper.getHeaders()); HttpEntity<String> request = new HttpEntity<>(restHelper.getHeaders());
ResponseEntity<ClassificationSummaryResource> response = ResponseEntity<ClassificationSummaryResource> response =
template.exchange( template.exchange(
@ -281,15 +293,17 @@ class ClassificationControllerIntTest {
HttpMethod.DELETE, HttpMethod.DELETE,
request, request,
ParameterizedTypeReference.forType(ClassificationSummaryResource.class)); ParameterizedTypeReference.forType(ClassificationSummaryResource.class));
assertThat(HttpStatus.NO_CONTENT).isEqualTo(response.getStatusCode());
assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
assertThatThrownBy(() -> assertThatThrownBy(
template.exchange( () ->
restHelper.toUrl( template.exchange(
Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"), restHelper.toUrl(
HttpMethod.GET, Mapping.URL_CLASSIFICATIONS_ID, "CLI:200000000000000000000000000000000004"),
request, HttpMethod.GET,
ParameterizedTypeReference.forType(ClassificationSummaryResource.class))) request,
.isInstanceOf(HttpClientErrorException.class); ParameterizedTypeReference.forType(ClassificationSummaryResource.class)))
.isInstanceOf(HttpClientErrorException.class);
} }
} }

View File

@ -1,12 +1,7 @@
package pro.taskana.rest; package pro.taskana.rest;
import static org.hamcrest.Matchers.instanceOf; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals; import static org.assertj.core.api.Assertions.fail;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.File; import java.io.File;
@ -62,10 +57,10 @@ class ClassificationDefinitionControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationResource[].class)); ParameterizedTypeReference.forType(ClassificationResource[].class));
assertEquals(HttpStatus.OK, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.OK);
assertTrue(response.getBody().length >= 5); assertThat(response.getBody().length >= 5).isTrue();
assertTrue(response.getBody().length <= 7); assertThat(response.getBody().length <= 7).isTrue();
assertThat(response.getBody()[0], instanceOf(ClassificationResource.class)); assertThat(response.getBody()[0]).isInstanceOf(ClassificationResource.class);
} }
@Test @Test
@ -76,7 +71,7 @@ class ClassificationDefinitionControllerIntTest {
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(ClassificationResource[].class)); ParameterizedTypeReference.forType(ClassificationResource[].class));
assertEquals(0, response.getBody().length); assertThat(response.getBody()).isEmpty();
} }
@Test @Test
@ -110,7 +105,7 @@ class ClassificationDefinitionControllerIntTest {
clList.add(objMapper.writeValueAsString(classification)); clList.add(objMapper.writeValueAsString(classification));
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
} }
@Test @Test
@ -123,7 +118,7 @@ class ClassificationDefinitionControllerIntTest {
try { try {
importRequest(clList); importRequest(clList);
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
} }
} }
@ -137,7 +132,7 @@ class ClassificationDefinitionControllerIntTest {
try { try {
importRequest(clList); importRequest(clList);
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
} }
} }
@ -152,7 +147,7 @@ class ClassificationDefinitionControllerIntTest {
try { try {
importRequest(clList); importRequest(clList);
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertThat(e.getStatusCode()).isEqualTo(HttpStatus.BAD_REQUEST);
} }
} }
@ -182,7 +177,7 @@ class ClassificationDefinitionControllerIntTest {
clList.add(c2); clList.add(c2);
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
} }
@Test @Test
@ -200,7 +195,7 @@ class ClassificationDefinitionControllerIntTest {
try { try {
importRequest(clList); importRequest(clList);
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.CONFLICT, e.getStatusCode()); assertThat(e.getStatusCode()).isEqualTo(HttpStatus.CONFLICT);
} }
} }
@ -213,18 +208,18 @@ class ClassificationDefinitionControllerIntTest {
clList.add(objMapper.writeValueAsString(existingClassification)); clList.add(objMapper.writeValueAsString(existingClassification));
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
existingClassification.setName("second new Name"); existingClassification.setName("second new Name");
clList = new ArrayList<>(); clList = new ArrayList<>();
clList.add(objMapper.writeValueAsString(existingClassification)); clList.add(objMapper.writeValueAsString(existingClassification));
response = importRequest(clList); response = importRequest(clList);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ClassificationSummaryResource testClassification = ClassificationSummaryResource testClassification =
this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
assertEquals("second new Name", testClassification.getName()); assertThat(testClassification.getName()).isEqualTo("second new Name");
} }
@Test @Test
@ -241,7 +236,7 @@ class ClassificationDefinitionControllerIntTest {
clList.add(objMapper.writeValueAsString(newClassification)); clList.add(objMapper.writeValueAsString(newClassification));
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ClassificationSummaryResource parentCl = ClassificationSummaryResource parentCl =
getClassificationWithKeyAndDomain("L11010", "DOMAIN_A"); getClassificationWithKeyAndDomain("L11010", "DOMAIN_A");
@ -250,11 +245,11 @@ class ClassificationDefinitionControllerIntTest {
ClassificationSummaryResource testExistingCl = ClassificationSummaryResource testExistingCl =
getClassificationWithKeyAndDomain("L110102", "DOMAIN_A"); getClassificationWithKeyAndDomain("L110102", "DOMAIN_A");
assertNotNull(parentCl); assertThat(parentCl).isNotNull();
assertNotNull(testNewCl); assertThat(testNewCl).isNotNull();
assertNotNull(testExistingCl); assertThat(testExistingCl).isNotNull();
assertEquals(testNewCl.getClassificationId(), testExistingCl.getParentId()); assertThat(testExistingCl.getParentId()).isEqualTo(testNewCl.getClassificationId());
assertEquals(parentCl.getClassificationId(), testNewCl.getParentId()); assertThat(testNewCl.getParentId()).isEqualTo(parentCl.getClassificationId());
} }
@Test @Test
@ -286,7 +281,7 @@ class ClassificationDefinitionControllerIntTest {
clList.add(c1); clList.add(c1);
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ClassificationSummaryResource parentCl = ClassificationSummaryResource parentCl =
getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A"); getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A");
@ -295,11 +290,11 @@ class ClassificationDefinitionControllerIntTest {
ClassificationSummaryResource grandchildCl = ClassificationSummaryResource grandchildCl =
getClassificationWithKeyAndDomain("ImportKey9", "DOMAIN_A"); getClassificationWithKeyAndDomain("ImportKey9", "DOMAIN_A");
assertNotNull(parentCl); assertThat(parentCl).isNotNull();
assertNotNull(childCl); assertThat(childCl).isNotNull();
assertNotNull(grandchildCl); assertThat(grandchildCl).isNotNull();
assertEquals(childCl.getClassificationId(), grandchildCl.getParentId()); assertThat(grandchildCl.getParentId()).isEqualTo(childCl.getClassificationId());
assertEquals(parentCl.getClassificationId(), childCl.getParentId()); assertThat(childCl.getParentId()).isEqualTo(parentCl.getClassificationId());
} }
@Test @Test
@ -321,7 +316,7 @@ class ClassificationDefinitionControllerIntTest {
clList.add(child); clList.add(child);
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ClassificationSummaryResource rightParentCl = ClassificationSummaryResource rightParentCl =
getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_A"); getClassificationWithKeyAndDomain("ImportKey11", "DOMAIN_A");
@ -330,11 +325,11 @@ class ClassificationDefinitionControllerIntTest {
ClassificationSummaryResource childCl = ClassificationSummaryResource childCl =
getClassificationWithKeyAndDomain("ImportKey13", "DOMAIN_A"); getClassificationWithKeyAndDomain("ImportKey13", "DOMAIN_A");
assertNotNull(rightParentCl); assertThat(rightParentCl).isNotNull();
assertNotNull(wrongParentCl); assertThat(wrongParentCl).isNotNull();
assertNotNull(childCl); assertThat(childCl).isNotNull();
assertEquals(rightParentCl.getClassificationId(), childCl.getParentId()); assertThat(childCl.getParentId()).isEqualTo(rightParentCl.getClassificationId());
assertNotEquals(wrongParentCl.getClassificationId(), childCl.getParentId()); assertThat(childCl.getParentId()).isNotEqualTo(wrongParentCl.getClassificationId());
} }
@Test @Test
@ -342,14 +337,14 @@ class ClassificationDefinitionControllerIntTest {
throws IOException, InterruptedException { throws IOException, InterruptedException {
ClassificationSummaryResource child1 = ClassificationSummaryResource child1 =
this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A");
assertEquals("L11010", child1.getParentKey()); assertThat(child1.getParentKey()).isEqualTo("L11010");
child1.setParentId("CLI:100000000000000000000000000000000002"); child1.setParentId("CLI:100000000000000000000000000000000002");
child1.setParentKey("L10303"); child1.setParentKey("L10303");
final String withNewParent = objMapper.writeValueAsString(child1); final String withNewParent = objMapper.writeValueAsString(child1);
ClassificationSummaryResource child2 = ClassificationSummaryResource child2 =
this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
assertEquals("L11010", child2.getParentKey()); assertThat(child2.getParentKey()).isEqualTo("L11010");
child2.setParentId(""); child2.setParentId("");
child2.setParentKey(""); child2.setParentKey("");
String withoutParent = objMapper.writeValueAsString(child2); String withoutParent = objMapper.writeValueAsString(child2);
@ -359,18 +354,18 @@ class ClassificationDefinitionControllerIntTest {
clList.add(withoutParent); clList.add(withoutParent);
ResponseEntity<Void> response = importRequest(clList); ResponseEntity<Void> response = importRequest(clList);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode()); assertThat(response.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
Thread.sleep(10); Thread.sleep(10);
LOGGER.debug("Wait 10 ms to give the system a chance to update"); LOGGER.debug("Wait 10 ms to give the system a chance to update");
ClassificationSummaryResource childWithNewParent = ClassificationSummaryResource childWithNewParent =
this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110105", "DOMAIN_A");
assertEquals(child1.parentKey, childWithNewParent.parentKey); assertThat(childWithNewParent.getParentKey()).isEqualTo(child1.getParentKey());
ClassificationSummaryResource childWithoutParent = ClassificationSummaryResource childWithoutParent =
this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A"); this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A");
assertEquals(child2.parentId, childWithoutParent.parentId); assertThat(childWithoutParent.getParentId()).isEqualTo(child2.getParentId());
assertEquals(child2.parentKey, childWithoutParent.parentKey); assertThat(childWithoutParent.getParentKey()).isEqualTo(child2.getParentKey());
} }
@Test @Test
@ -387,7 +382,7 @@ class ClassificationDefinitionControllerIntTest {
importRequest(clList); importRequest(clList);
fail("Expected http-Status 409"); fail("Expected http-Status 409");
} catch (HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.CONFLICT, e.getStatusCode()); assertThat(e.getStatusCode()).isEqualTo(HttpStatus.CONFLICT);
} }
} }
@ -405,7 +400,7 @@ class ClassificationDefinitionControllerIntTest {
private ClassificationSummaryResource getClassificationWithKeyAndDomain( private ClassificationSummaryResource getClassificationWithKeyAndDomain(
String key, String domain) { String key, String domain) {
LOGGER.debug("Request classification with key={} in domain={}", key, domain); LOGGER.debug("Request classification with key={} in domain={}", key, domain);
HttpEntity<String> request = new HttpEntity<String>(restHelper.getHeaders()); HttpEntity<String> request = new HttpEntity<>(restHelper.getHeaders());
ResponseEntity<ClassificationSummaryListResource> response = ResponseEntity<ClassificationSummaryListResource> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?key=" + key + "&domain=" + domain, restHelper.toUrl(Mapping.URL_CLASSIFICATIONS) + "?key=" + key + "&domain=" + domain,

View File

@ -165,18 +165,18 @@ class TaskControllerIntTest {
@Test @Test
void testGetAllTasksByWorkbasketIdWithInvalidPlannedParamsCombination() { void testGetAllTasksByWorkbasketIdWithInvalidPlannedParamsCombination() {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "?workbasket-id=WBI:100000000000000000000000000000000001"
+ "&planned=2020-01-22T09:44:47.453Z,," + "&planned=2020-01-22T09:44:47.453Z,,"
+ "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z," + "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z,"
+ ",2020-01-18T09:44:47.453Z" + ",2020-01-18T09:44:47.453Z"
+ "&planned-from=2020-01-19T07:44:47.453Z" + "&planned-from=2020-01-19T07:44:47.453Z"
+ "&sort-by=planned", + "&sort-by=planned",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class))) ParameterizedTypeReference.forType(TaskSummaryListResource.class)))
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("400"); .hasMessageContaining("400");
} }
@ -255,17 +255,17 @@ class TaskControllerIntTest {
void testGetAllTasksByWorkbasketIdWithInvalidDueParamsCombination() { void testGetAllTasksByWorkbasketIdWithInvalidDueParamsCombination() {
assertThatThrownBy( assertThatThrownBy(
() -> () ->
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
+ "?workbasket-id=WBI:100000000000000000000000000000000001" + "?workbasket-id=WBI:100000000000000000000000000000000001"
+ "&due=2020-01-22T09:44:47.453Z,," + "&due=2020-01-22T09:44:47.453Z,,"
+ "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z," + "2020-01-19T07:44:47.453Z,2020-01-19T19:44:47.453Z,"
+ ",2020-01-18T09:44:47.453Z" + ",2020-01-18T09:44:47.453Z"
+ "&due-from=2020-01-19T07:44:47.453Z" + "&due-from=2020-01-19T07:44:47.453Z"
+ "&sort-by=planned", + "&sort-by=planned",
HttpMethod.GET, HttpMethod.GET,
restHelper.defaultRequest(), restHelper.defaultRequest(),
ParameterizedTypeReference.forType(TaskSummaryListResource.class))) ParameterizedTypeReference.forType(TaskSummaryListResource.class)))
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("400"); .hasMessageContaining("400");
} }
@ -274,7 +274,7 @@ class TaskControllerIntTest {
void testGetAllTasksByWorkbasketKeyAndDomain() { void testGetAllTasksByWorkbasketKeyAndDomain() {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2 headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<>(headers);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskSummaryListResource> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2&domain=DOMAIN_A", restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2&domain=DOMAIN_A",
@ -290,17 +290,17 @@ class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2 headers.add("Authorization", "Basic dXNlcl8xXzI6dXNlcl8xXzI="); // user_1_2
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<>(headers);
assertThatThrownBy( assertThatThrownBy(
() -> { () -> {
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskSummaryListResource> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2", restHelper.toUrl(Mapping.URL_TASKS) + "?workbasket-key=USER_1_2",
HttpMethod.GET, HttpMethod.GET,
request, request,
ParameterizedTypeReference.forType(TaskSummaryListResource.class)); ParameterizedTypeReference.forType(TaskSummaryListResource.class));
}) })
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("400"); .hasMessageContaining("400");
} }
@ -355,7 +355,7 @@ class TaskControllerIntTest {
@Test @Test
void testGetLastPageSortedByPorValue() { void testGetLastPageSortedByPorValue() {
HttpEntity<String> request = new HttpEntity<String>(restHelper.getHeadersAdmin()); HttpEntity<String> request = new HttpEntity<>(restHelper.getHeadersAdmin());
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskSummaryListResource> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
@ -393,7 +393,7 @@ class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<>(headers);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskSummaryListResource> response =
template.exchange( template.exchange(
@ -436,7 +436,7 @@ class TaskControllerIntTest {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
HttpEntity<String> request = new HttpEntity<String>(headers); HttpEntity<String> request = new HttpEntity<>(headers);
ResponseEntity<TaskSummaryListResource> response = ResponseEntity<TaskSummaryListResource> response =
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS) restHelper.toUrl(Mapping.URL_TASKS)
@ -586,12 +586,12 @@ class TaskControllerIntTest {
taskResource.setDue(now.toString()); taskResource.setDue(now.toString());
assertThatThrownBy( assertThatThrownBy(
() -> () ->
template.exchange( template.exchange(
restHelper.toUrl(Mapping.URL_TASKS), restHelper.toUrl(Mapping.URL_TASKS),
HttpMethod.POST, HttpMethod.POST,
new HttpEntity<>(taskResource, restHelper.getHeaders()), new HttpEntity<>(taskResource, restHelper.getHeaders()),
ParameterizedTypeReference.forType(TaskResource.class))) ParameterizedTypeReference.forType(TaskResource.class)))
.isInstanceOf(HttpClientErrorException.class); .isInstanceOf(HttpClientErrorException.class);
} }
@ -640,7 +640,7 @@ class TaskControllerIntTest {
} }
@Test @Test
void testUpdateTaskOwnerOfReadyTaskSucceeds() throws IOException { void testUpdateTaskOwnerOfReadyTaskSucceeds() {
// setup // setup
final String taskUrlString = final String taskUrlString =
restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000025"); restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000025");
@ -648,10 +648,10 @@ class TaskControllerIntTest {
// retrieve task from Rest Api // retrieve task from Rest Api
ResponseEntity<TaskResource> responseGet = ResponseEntity<TaskResource> responseGet =
template.exchange( template.exchange(
taskUrlString, taskUrlString,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<>(getHeadersForUser_1_2()), new HttpEntity<>(getHeadersForUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskResource.class));
assertThat(responseGet.getBody()).isNotNull(); assertThat(responseGet.getBody()).isNotNull();
TaskResource theTaskResource = responseGet.getBody(); TaskResource theTaskResource = responseGet.getBody();
@ -664,10 +664,10 @@ class TaskControllerIntTest {
theTaskResource.setOwner(anyUserName); theTaskResource.setOwner(anyUserName);
ResponseEntity<TaskResource> responseUpdate = ResponseEntity<TaskResource> responseUpdate =
template.exchange( template.exchange(
taskUrlString, taskUrlString,
HttpMethod.PUT, HttpMethod.PUT,
new HttpEntity<>(theTaskResource, getHeadersForUser_1_2()), new HttpEntity<>(theTaskResource, getHeadersForUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskResource.class));
assertThat(responseUpdate.getBody()).isNotNull(); assertThat(responseUpdate.getBody()).isNotNull();
TaskResource theUpdatedTaskResource = responseUpdate.getBody(); TaskResource theUpdatedTaskResource = responseUpdate.getBody();
@ -676,7 +676,7 @@ class TaskControllerIntTest {
} }
@Test @Test
void testUpdateTaskOwnerOfClaimedTaskFails() throws IOException { void testUpdateTaskOwnerOfClaimedTaskFails() {
// setup // setup
final String taskUrlString = final String taskUrlString =
restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000026"); restHelper.toUrl("/api/v1/tasks/TKI:000000000000000000000000000000000026");
@ -684,10 +684,10 @@ class TaskControllerIntTest {
// retrieve task from Rest Api // retrieve task from Rest Api
ResponseEntity<TaskResource> responseGet = ResponseEntity<TaskResource> responseGet =
template.exchange( template.exchange(
taskUrlString, taskUrlString,
HttpMethod.GET, HttpMethod.GET,
new HttpEntity<>(getHeadersForUser_1_2()), new HttpEntity<>(getHeadersForUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class)); ParameterizedTypeReference.forType(TaskResource.class));
assertThat(responseGet.getBody()).isNotNull(); assertThat(responseGet.getBody()).isNotNull();
TaskResource theTaskResource = responseGet.getBody(); TaskResource theTaskResource = responseGet.getBody();
@ -700,12 +700,12 @@ class TaskControllerIntTest {
theTaskResource.setOwner(anyUserName); theTaskResource.setOwner(anyUserName);
assertThatThrownBy( assertThatThrownBy(
() -> () ->
template.exchange( template.exchange(
taskUrlString, taskUrlString,
HttpMethod.PUT, HttpMethod.PUT,
new HttpEntity<>(theTaskResource, getHeadersForUser_1_2()), new HttpEntity<>(theTaskResource, getHeadersForUser_1_2()),
ParameterizedTypeReference.forType(TaskResource.class))) ParameterizedTypeReference.forType(TaskResource.class)))
.isInstanceOf(HttpClientErrorException.class) .isInstanceOf(HttpClientErrorException.class)
.hasMessageContaining("409"); .hasMessageContaining("409");
} }
@ -719,7 +719,7 @@ class TaskControllerIntTest {
private TaskResource getTaskResourceSample() { private TaskResource getTaskResourceSample() {
ClassificationSummaryResource classificationResource = new ClassificationSummaryResource(); ClassificationSummaryResource classificationResource = new ClassificationSummaryResource();
classificationResource.key = "L11010"; classificationResource.setKey("L11010");
WorkbasketSummaryResource workbasketSummaryResource = new WorkbasketSummaryResource(); WorkbasketSummaryResource workbasketSummaryResource = new WorkbasketSummaryResource();
workbasketSummaryResource.setWorkbasketId("WBI:100000000000000000000000000000000004"); workbasketSummaryResource.setWorkbasketId("WBI:100000000000000000000000000000000004");

View File

@ -1,7 +1,8 @@
package pro.taskana.rest.resource; package pro.taskana.rest.resource;
import static org.assertj.core.api.Assertions.assertThat;
import java.time.Instant; import java.time.Instant;
import org.junit.Assert;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -78,22 +79,22 @@ class ClassificationSummaryAssemblerTest {
private void testEquality( private void testEquality(
ClassificationSummary classificationSummary, ClassificationSummaryResource resource) { ClassificationSummary classificationSummary, ClassificationSummaryResource resource) {
Assert.assertEquals(classificationSummary.getKey(), resource.key); assertThat(resource.getKey()).isEqualTo(classificationSummary.getKey());
Assert.assertEquals(classificationSummary.getDomain(), resource.domain); assertThat(resource.getDomain()).isEqualTo(classificationSummary.getDomain());
Assert.assertEquals(classificationSummary.getId(), resource.classificationId); assertThat(resource.getClassificationId()).isEqualTo(classificationSummary.getId());
Assert.assertEquals(classificationSummary.getName(), resource.name); assertThat(resource.getName()).isEqualTo(classificationSummary.getName());
Assert.assertEquals(classificationSummary.getCategory(), resource.category); assertThat(resource.getCategory()).isEqualTo(classificationSummary.getCategory());
Assert.assertEquals(classificationSummary.getCustom1(), resource.custom1); assertThat(resource.getCustom1()).isEqualTo(classificationSummary.getCustom1());
Assert.assertEquals(classificationSummary.getCustom2(), resource.custom2); assertThat(resource.getCustom2()).isEqualTo(classificationSummary.getCustom2());
Assert.assertEquals(classificationSummary.getCustom3(), resource.custom3); assertThat(resource.getCustom3()).isEqualTo(classificationSummary.getCustom3());
Assert.assertEquals(classificationSummary.getCustom4(), resource.custom4); assertThat(resource.getCustom4()).isEqualTo(classificationSummary.getCustom4());
Assert.assertEquals(classificationSummary.getCustom5(), resource.custom5); assertThat(resource.getCustom5()).isEqualTo(classificationSummary.getCustom5());
Assert.assertEquals(classificationSummary.getCustom6(), resource.custom6); assertThat(resource.getCustom6()).isEqualTo(classificationSummary.getCustom6());
Assert.assertEquals(classificationSummary.getCustom7(), resource.custom7); assertThat(resource.getCustom7()).isEqualTo(classificationSummary.getCustom7());
Assert.assertEquals(classificationSummary.getCustom8(), resource.custom8); assertThat(resource.getCustom8()).isEqualTo(classificationSummary.getCustom8());
Assert.assertEquals(classificationSummary.getParentId(), resource.parentId); assertThat(resource.getParentId()).isEqualTo(classificationSummary.getParentId());
Assert.assertEquals(classificationSummary.getParentKey(), resource.parentKey); assertThat(resource.getParentKey()).isEqualTo(classificationSummary.getParentKey());
Assert.assertEquals(classificationSummary.getType(), resource.type); assertThat(resource.getType()).isEqualTo(classificationSummary.getType());
Assert.assertEquals(classificationSummary.getPriority(), resource.priority); assertThat(resource.getPriority()).isEqualTo(classificationSummary.getPriority());
} }
} }

View File

@ -1,10 +1,11 @@
package pro.taskana.rest.resource; package pro.taskana.rest.resource;
import static org.assertj.core.api.Assertions.assertThat;
import java.time.Instant; import java.time.Instant;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.Assert;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -40,9 +41,9 @@ class TaskResourceAssemberTest {
WorkbasketSummaryResource workbasketResource = new WorkbasketSummaryResource(); WorkbasketSummaryResource workbasketResource = new WorkbasketSummaryResource();
workbasketResource.setWorkbasketId("workbasketId"); workbasketResource.setWorkbasketId("workbasketId");
ClassificationSummaryResource classificationResource = new ClassificationSummaryResource(); ClassificationSummaryResource classificationResource = new ClassificationSummaryResource();
classificationResource.key = "keyabc"; classificationResource.setKey("keyabc");
classificationResource.domain = "DOMAIN_A"; classificationResource.setDomain("DOMAIN_A");
classificationResource.type = "MANUAL"; classificationResource.setType("MANUAL");
AttachmentResource attachement = new AttachmentResource(); AttachmentResource attachement = new AttachmentResource();
attachement.setClassificationSummary(classificationResource); attachement.setClassificationSummary(classificationResource);
attachement.setAttachmentId("attachementId"); attachement.setAttachmentId("attachementId");
@ -155,82 +156,79 @@ class TaskResourceAssemberTest {
} }
void testEquality(Task task, TaskResource resource) throws InvalidArgumentException { void testEquality(Task task, TaskResource resource) throws InvalidArgumentException {
Assert.assertEquals(task.getId(), resource.getTaskId()); assertThat(resource.getTaskId()).isEqualTo(task.getId());
Assert.assertEquals(task.getExternalId(), resource.getExternalId()); assertThat(resource.getExternalId()).isEqualTo(task.getExternalId());
Assert.assertEquals( assertThat(resource.getCreated())
task.getCreated() == null ? null : task.getCreated().toString(), resource.getCreated()); .isEqualTo(task.getCreated() == null ? null : task.getCreated().toString());
Assert.assertEquals( assertThat(resource.getClaimed())
task.getClaimed() == null ? null : task.getClaimed().toString(), resource.getClaimed()); .isEqualTo(task.getClaimed() == null ? null : task.getClaimed().toString());
Assert.assertEquals( assertThat(resource.getCompleted())
task.getCompleted() == null ? null : task.getCompleted().toString(), .isEqualTo(task.getCompleted() == null ? null : task.getCompleted().toString());
resource.getCompleted()); assertThat(resource.getModified())
Assert.assertEquals( .isEqualTo(task.getModified() == null ? null : task.getModified().toString());
task.getModified() == null ? null : task.getModified().toString(), resource.getModified()); assertThat(resource.getPlanned())
Assert.assertEquals( .isEqualTo(task.getPlanned() == null ? null : task.getPlanned().toString());
task.getPlanned() == null ? null : task.getPlanned().toString(), resource.getPlanned()); assertThat(resource.getDue())
Assert.assertEquals(task.getDue() == null ? null : task.getDue().toString(), resource.getDue()); .isEqualTo(task.getDue() == null ? null : task.getDue().toString());
Assert.assertEquals(task.getName(), resource.getName()); assertThat(resource.getName()).isEqualTo(task.getName());
Assert.assertEquals(task.getCreator(), resource.getCreator()); assertThat(resource.getCreator()).isEqualTo(task.getCreator());
Assert.assertEquals(task.getDescription(), resource.getDescription()); assertThat(resource.getDescription()).isEqualTo(task.getDescription());
Assert.assertEquals(task.getNote(), resource.getNote()); assertThat(resource.getNote()).isEqualTo(task.getNote());
Assert.assertEquals(task.getPriority(), resource.getPriority()); assertThat(resource.getPriority()).isEqualTo(task.getPriority());
Assert.assertEquals(task.getState(), resource.getState()); assertThat(resource.getState()).isEqualTo(task.getState());
Assert.assertEquals( assertThat(resource.getClassificationSummaryResource().getClassificationId())
task.getClassificationSummary().getId(), .isEqualTo(task.getClassificationSummary().getId());
resource.getClassificationSummaryResource().getClassificationId()); assertThat(resource.getWorkbasketSummaryResource().getWorkbasketId())
Assert.assertEquals( .isEqualTo(task.getWorkbasketSummary().getId());
task.getWorkbasketSummary().getId(), assertThat(resource.getBusinessProcessId()).isEqualTo(task.getBusinessProcessId());
resource.getWorkbasketSummaryResource().getWorkbasketId()); assertThat(resource.getParentBusinessProcessId()).isEqualTo(task.getParentBusinessProcessId());
Assert.assertEquals(task.getBusinessProcessId(), resource.getBusinessProcessId()); assertThat(resource.getOwner()).isEqualTo(task.getOwner());
Assert.assertEquals(task.getParentBusinessProcessId(), resource.getParentBusinessProcessId()); assertThat(resource.getPrimaryObjRef()).isEqualTo(task.getPrimaryObjRef());
Assert.assertEquals(task.getOwner(), resource.getOwner()); assertThat(resource.isRead()).isEqualTo(task.isRead());
Assert.assertEquals(task.getPrimaryObjRef(), resource.getPrimaryObjRef()); assertThat(resource.isTransferred()).isEqualTo(task.isTransferred());
Assert.assertEquals(task.isRead(), resource.isRead());
Assert.assertEquals(task.isTransferred(), resource.isTransferred());
testEquality(task.getCustomAttributes(), resource.getCustomAttributes()); testEquality(task.getCustomAttributes(), resource.getCustomAttributes());
testEquality(task.getCallbackInfo(), resource.getCallbackInfo()); testEquality(task.getCallbackInfo(), resource.getCallbackInfo());
testEqualityAttachements(task.getAttachments(), resource.getAttachments()); testEqualityAttachements(task.getAttachments(), resource.getAttachments());
Assert.assertEquals(task.getCustomAttribute("1"), resource.getCustom1()); assertThat(resource.getCustom1()).isEqualTo(task.getCustomAttribute("1"));
Assert.assertEquals(task.getCustomAttribute("2"), resource.getCustom2()); assertThat(resource.getCustom2()).isEqualTo(task.getCustomAttribute("2"));
Assert.assertEquals(task.getCustomAttribute("3"), resource.getCustom3()); assertThat(resource.getCustom3()).isEqualTo(task.getCustomAttribute("3"));
Assert.assertEquals(task.getCustomAttribute("4"), resource.getCustom4()); assertThat(resource.getCustom4()).isEqualTo(task.getCustomAttribute("4"));
Assert.assertEquals(task.getCustomAttribute("5"), resource.getCustom5()); assertThat(resource.getCustom5()).isEqualTo(task.getCustomAttribute("5"));
Assert.assertEquals(task.getCustomAttribute("6"), resource.getCustom6()); assertThat(resource.getCustom6()).isEqualTo(task.getCustomAttribute("6"));
Assert.assertEquals(task.getCustomAttribute("7"), resource.getCustom7()); assertThat(resource.getCustom7()).isEqualTo(task.getCustomAttribute("7"));
Assert.assertEquals(task.getCustomAttribute("8"), resource.getCustom8()); assertThat(resource.getCustom8()).isEqualTo(task.getCustomAttribute("8"));
Assert.assertEquals(task.getCustomAttribute("9"), resource.getCustom9()); assertThat(resource.getCustom9()).isEqualTo(task.getCustomAttribute("9"));
Assert.assertEquals(task.getCustomAttribute("10"), resource.getCustom10()); assertThat(resource.getCustom10()).isEqualTo(task.getCustomAttribute("10"));
Assert.assertEquals(task.getCustomAttribute("11"), resource.getCustom11()); assertThat(resource.getCustom11()).isEqualTo(task.getCustomAttribute("11"));
Assert.assertEquals(task.getCustomAttribute("12"), resource.getCustom12()); assertThat(resource.getCustom12()).isEqualTo(task.getCustomAttribute("12"));
Assert.assertEquals(task.getCustomAttribute("13"), resource.getCustom13()); assertThat(resource.getCustom13()).isEqualTo(task.getCustomAttribute("13"));
Assert.assertEquals(task.getCustomAttribute("14"), resource.getCustom14()); assertThat(resource.getCustom14()).isEqualTo(task.getCustomAttribute("14"));
Assert.assertEquals(task.getCustomAttribute("15"), resource.getCustom15()); assertThat(resource.getCustom15()).isEqualTo(task.getCustomAttribute("15"));
Assert.assertEquals(task.getCustomAttribute("16"), resource.getCustom16()); assertThat(resource.getCustom16()).isEqualTo(task.getCustomAttribute("16"));
} }
private void testEquality( private void testEquality(
Map<String, String> customAttributes, List<TaskResource.CustomAttribute> resourceAttributes) { Map<String, String> customAttributes, List<TaskResource.CustomAttribute> resourceAttributes) {
Assert.assertEquals(customAttributes.size(), resourceAttributes.size()); assertThat(resourceAttributes).hasSize(customAttributes.size());
resourceAttributes.forEach( resourceAttributes.forEach(
attribute -> attribute ->
Assert.assertEquals(customAttributes.get(attribute.getKey()), attribute.getValue())); assertThat(attribute.getValue()).isEqualTo(customAttributes.get(attribute.getKey())));
} }
private void testEqualityAttachements( private void testEqualityAttachements(
List<Attachment> attachments, List<AttachmentResource> resources) { List<Attachment> attachments, List<AttachmentResource> resources) {
Assert.assertEquals(attachments.size(), resources.size()); assertThat(resources).hasSize(attachments.size());
for (int i = 0; i < resources.size(); i++) { for (int i = 0; i < resources.size(); i++) {
AttachmentResource resource = resources.get(i); AttachmentResource resource = resources.get(i);
Attachment attachment = attachments.get(i); Attachment attachment = attachments.get(i);
// Anything else shoulde be tested in AttachementResourceAssemblerTest // Anything else should be be tested in AttachementResourceAssemblerTest
Assert.assertEquals(attachment.getId(), resource.getAttachmentId()); assertThat(resource.getAttachmentId()).isEqualTo(attachment.getId());
} }
} }
private void testLinks(TaskResource resource) { private void testLinks(TaskResource resource) {
Assert.assertEquals(1, resource.getLinks().size()); assertThat(resource.getLinks()).hasSize(1);
Assert.assertEquals( assertThat(resource.getLink("self").getHref())
Mapping.URL_TASKS_ID.replaceAll("\\{.*}", resource.getTaskId()), .isEqualTo(Mapping.URL_TASKS_ID.replaceAll("\\{.*}", resource.getTaskId()));
resource.getLink("self").getHref());
} }
} }