diff --git a/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/TaskHistoryEventController.java b/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/TaskHistoryEventController.java index 2e3506b6a..d75ce09ed 100644 --- a/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/TaskHistoryEventController.java +++ b/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/TaskHistoryEventController.java @@ -100,7 +100,7 @@ public class TaskHistoryEventController extends AbstractPagingController { @Transactional(readOnly = true, rollbackFor = Exception.class) public ResponseEntity> getTaskHistoryEvent( @RequestParam MultiValueMap params) throws InvalidArgumentException { - if(LOGGER.isDebugEnabled()) { + if (LOGGER.isDebugEnabled()) { LOGGER.debug("Entry to getTaskHistoryEvent(params= {})", LoggerUtils.mapToString(params)); } @@ -129,7 +129,7 @@ public class TaskHistoryEventController extends AbstractPagingController { TaskHistoryEventListAssembler assembler = new TaskHistoryEventListAssembler(); PagedResources pagedResources = assembler.toResources(historyEvents, pageMetadata); - if(LOGGER.isDebugEnabled()) { + if (LOGGER.isDebugEnabled()) { LOGGER.debug("Exit from getTaskHistoryEvent(), returning {}", new ResponseEntity<>(pagedResources, HttpStatus.OK)); } @@ -138,7 +138,7 @@ public class TaskHistoryEventController extends AbstractPagingController { private HistoryQuery applySortingParams(HistoryQuery query, MultiValueMap params) throws IllegalArgumentException, InvalidArgumentException { - if(LOGGER.isDebugEnabled()) { + if (LOGGER.isDebugEnabled()) { LOGGER.debug("Entry to applySortingParams(params= {})", LoggerUtils.mapToString(params)); } @@ -217,7 +217,7 @@ public class TaskHistoryEventController extends AbstractPagingController { } params.remove(SORT_BY); params.remove(SORT_DIRECTION); - if(LOGGER.isDebugEnabled()) { + if (LOGGER.isDebugEnabled()) { LOGGER.debug("Exit from applySortingParams(), returning {}", query); } @@ -226,7 +226,7 @@ public class TaskHistoryEventController extends AbstractPagingController { private HistoryQuery applyFilterParams(HistoryQuery query, MultiValueMap params) { - if(LOGGER.isDebugEnabled()) { + if (LOGGER.isDebugEnabled()) { LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params); } @@ -404,7 +404,7 @@ public class TaskHistoryEventController extends AbstractPagingController { query.custom4Like(LIKE + params.get(CUSTOM_4_LIKE).get(0) + LIKE); params.remove(CUSTOM_4_LIKE); } - if(LOGGER.isDebugEnabled()) { + if (LOGGER.isDebugEnabled()) { LOGGER.debug("Exit from applyFilterParams(), returning {}", query); } diff --git a/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/resource/TaskHistoryEventResource.java b/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/resource/TaskHistoryEventResource.java index 5eaa2fffd..ad01322f1 100644 --- a/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/resource/TaskHistoryEventResource.java +++ b/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/resource/TaskHistoryEventResource.java @@ -247,20 +247,20 @@ public class TaskHistoryEventResource extends ResourceSupport { @Override public String toString() { - return "TaskHistoryEventResource [" + - "taskHistoryEventId= " + this.taskHistoryEventId + - "businessProcessId= " + this.businessProcessId + - "parentBusinessProcessId= " + this.parentBusinessProcessId + - "taskId= " + this.taskId + - "eventType= " + this.eventType + - "created= " + this.created + - "userId= " + this.userId + - "domain= " + this.domain + - "workbasketKey= " + this.workbasketKey + - "oldValue= " + this.oldValue + - "newValue= " + this.newValue + - "oldData= " + this.oldData + - "newData= " + this.newData + - "]"; + return "TaskHistoryEventResource [" + + "taskHistoryEventId= " + this.taskHistoryEventId + + "businessProcessId= " + this.businessProcessId + + "parentBusinessProcessId= " + this.parentBusinessProcessId + + "taskId= " + this.taskId + + "eventType= " + this.eventType + + "created= " + this.created + + "userId= " + this.userId + + "domain= " + this.domain + + "workbasketKey= " + this.workbasketKey + + "oldValue= " + this.oldValue + + "newValue= " + this.newValue + + "oldData= " + this.oldData + + "newData= " + this.newData + + "]"; } } diff --git a/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/sampledata/SampleDataGenerator.java b/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/sampledata/SampleDataGenerator.java index 07de7477e..5b7bbd453 100644 --- a/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/sampledata/SampleDataGenerator.java +++ b/rest/taskana-history-rest-spring/src/main/java/pro/taskana/rest/sampledata/SampleDataGenerator.java @@ -67,9 +67,9 @@ public class SampleDataGenerator { } private StringReader selectSchemaScript(String dbProductName, String schemaName) { - return new StringReader("PostgreSQL".equals(dbProductName) ? - "SET search_path TO " + schemaName + ";" : - "SET SCHEMA " + schemaName + ";"); + return new StringReader("PostgreSQL".equals(dbProductName) + ? "SET search_path TO " + schemaName + ";" + : "SET SCHEMA " + schemaName + ";"); } } diff --git a/rest/taskana-history-rest-spring/src/test/java/pro/taskana/historyPlugin/doc/api/TaskHistoryEventControllerRestDocumentation.java b/rest/taskana-history-rest-spring/src/test/java/pro/taskana/historyPlugin/doc/api/TaskHistoryEventControllerRestDocumentation.java index b6a2c1f1a..ae9d4fb32 100644 --- a/rest/taskana-history-rest-spring/src/test/java/pro/taskana/historyPlugin/doc/api/TaskHistoryEventControllerRestDocumentation.java +++ b/rest/taskana-history-rest-spring/src/test/java/pro/taskana/historyPlugin/doc/api/TaskHistoryEventControllerRestDocumentation.java @@ -31,6 +31,9 @@ import org.springframework.web.context.WebApplicationContext; import pro.taskana.historyPlugin.config.TaskHistoryRestConfiguration; import pro.taskana.rest.RestConfiguration; +/** + * Controller for Rest documentation. + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = {RestConfiguration.class, TaskHistoryRestConfiguration.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class TaskHistoryEventControllerRestDocumentation { @@ -64,36 +67,36 @@ public class TaskHistoryEventControllerRestDocumentation { .withRequestDefaults(prettyPrint())) .build(); - taskHistoryEventFieldDescriptionsMap.put("_embedded.taskHistoryId","Unique ID"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.businessProcessId","The id of the business process"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.parentBusinessProcessId","The id of the parent business process"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.taskId","The id of the task"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.eventType","The type of the event"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.created","The time was created"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.userId","The id of the user"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.domain","Domain"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.workbasketKey","The key of workbasket"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.porCompany",""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.porSystem",""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.porInstance",""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.porValue",""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.porType",""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationKey","The key of classification task"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationCategory","The category of classification"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.attachmentClassificationKey",""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.comment",""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.oldValue","The old value"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.newValue","The new value"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.custom1","A custom property with name \"1\""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.custom2","A custom property with name \"2\""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.custom3","A custom property with name \"3\""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.custom4","A custom property with name \"4\""); - taskHistoryEventFieldDescriptionsMap.put("_embedded.oldData","The old data"); - taskHistoryEventFieldDescriptionsMap.put("_embedded.newData","The new data"); - taskHistoryEventFieldDescriptionsMap.put("_links.self.href","The links of this task history event"); - taskHistoryEventFieldDescriptionsMap.put("_links.allTaskHistoryEvent.href","Link to all task history event"); - taskHistoryEventFieldDescriptionsMap.put("_links.first.href","Link to the first result"); - taskHistoryEventFieldDescriptionsMap.put("_links.last.href","Link to the last result"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.taskHistoryId", "Unique ID"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.businessProcessId", "The id of the business process"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.parentBusinessProcessId", "The id of the parent business process"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.taskId", "The id of the task"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.eventType", "The type of the event"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.created", "The time was created"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.userId", "The id of the user"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.domain", "Domain"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.workbasketKey", "The key of workbasket"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.porCompany", ""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.porSystem", ""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.porInstance", ""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.porValue", ""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.porType", ""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationKey", "The key of classification task"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationCategory", "The category of classification"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.attachmentClassificationKey", ""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.comment", ""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.oldValue", "The old value"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.newValue", "The new value"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.custom1", "A custom property with name \"1\""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.custom2", "A custom property with name \"2\""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.custom3", "A custom property with name \"3\""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.custom4", "A custom property with name \"4\""); + taskHistoryEventFieldDescriptionsMap.put("_embedded.oldData", "The old data"); + taskHistoryEventFieldDescriptionsMap.put("_embedded.newData", "The new data"); + taskHistoryEventFieldDescriptionsMap.put("_links.self.href", "The links of this task history event"); + taskHistoryEventFieldDescriptionsMap.put("_links.allTaskHistoryEvent.href", "Link to all task history event"); + taskHistoryEventFieldDescriptionsMap.put("_links.first.href", "Link to the first result"); + taskHistoryEventFieldDescriptionsMap.put("_links.last.href", "Link to the last result"); allTaskHistoryEventFieldDescriptors = new FieldDescriptor[] { subsectionWithPath("_embedded.taskHistoryEventResourceList").description("An array of Task history event"), diff --git a/rest/taskana-history-rest-spring/src/test/java/pro/taskana/historyPlugin/rest/TaskHistoryEventControllerIntTest.java b/rest/taskana-history-rest-spring/src/test/java/pro/taskana/historyPlugin/rest/TaskHistoryEventControllerIntTest.java index 50ec449f6..3232c3875 100644 --- a/rest/taskana-history-rest-spring/src/test/java/pro/taskana/historyPlugin/rest/TaskHistoryEventControllerIntTest.java +++ b/rest/taskana-history-rest-spring/src/test/java/pro/taskana/historyPlugin/rest/TaskHistoryEventControllerIntTest.java @@ -37,6 +37,10 @@ import pro.taskana.historyPlugin.config.TaskHistoryRestConfiguration; import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.resource.TaskHistoryEventResource; +/** + * Controller for integration test. + */ + @RunWith(SpringRunner.class) @SpringBootTest(classes = {RestConfiguration.class, TaskHistoryRestConfiguration.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) @@ -138,7 +142,7 @@ public class TaskHistoryEventControllerIntTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ diff --git a/rest/taskana-rest-spring-example/.project b/rest/taskana-rest-spring-example/.project index 8293ae6aa..e56b84f3e 100644 --- a/rest/taskana-rest-spring-example/.project +++ b/rest/taskana-rest-spring-example/.project @@ -15,9 +15,15 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.jdt.core.javanature org.eclipse.m2e.core.maven2Nature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/ldap/LdapCacheTestImpl.java b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/ldap/LdapCacheTestImpl.java index 0aa5b9458..d90ad6dc3 100644 --- a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/ldap/LdapCacheTestImpl.java +++ b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/ldap/LdapCacheTestImpl.java @@ -362,6 +362,8 @@ public class LdapCacheTestImpl implements LdapCache { case 3: group3.add(group); break; + default: + break; } groupNumber = (groupNumber + 1) % 4; } @@ -382,6 +384,8 @@ public class LdapCacheTestImpl implements LdapCache { case 3: users.put(item, group3); break; + default: + break; } } countUser = (countUser + 1) % 4; diff --git a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/ExampleRestApplication.java b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/ExampleRestApplication.java index 5dd7ba00b..3d90388a5 100644 --- a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/ExampleRestApplication.java +++ b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/ExampleRestApplication.java @@ -43,7 +43,7 @@ public class ExampleRestApplication { @Autowired private SampleDataGenerator sampleDataGenerator; - + @Autowired private LdapClient ldapClient; @@ -85,7 +85,7 @@ public class ExampleRestApplication { AccessIdController.setLdapCache(ldapCacheTest); } if (generateSampleData) { - sampleDataGenerator.generateSampleData(schemaName); + sampleDataGenerator.generateSampleData(schemaName); } } } diff --git a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/WebMvcConfig.java b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/WebMvcConfig.java index 9169f6099..3f5e1dea6 100644 --- a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/WebMvcConfig.java +++ b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/WebMvcConfig.java @@ -14,7 +14,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; - +/** + * The Web MVC Configuration. + * + */ @Configuration @EnableWebMvc public class WebMvcConfig implements WebMvcConfigurer { diff --git a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/controllers/LoginController.java b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/controllers/LoginController.java index 8542b14bd..8ce1edbde 100644 --- a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/controllers/LoginController.java +++ b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/controllers/LoginController.java @@ -7,6 +7,9 @@ import org.springframework.stereotype.Controller; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +/** + * The login controller. + */ @Controller public class LoginController implements WebMvcConfigurer { private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class); diff --git a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/controllers/ViewController.java b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/controllers/ViewController.java index 3876327d1..f8c93de9f 100644 --- a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/controllers/ViewController.java +++ b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/controllers/ViewController.java @@ -3,6 +3,9 @@ package pro.taskana.rest.controllers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; +/** + * The view controller. + */ @Controller public class ViewController { diff --git a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/models/User.java b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/models/User.java index b70780796..533af5fb4 100644 --- a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/models/User.java +++ b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/models/User.java @@ -1,5 +1,8 @@ package pro.taskana.rest.models; - +/** + * model for a user. + * + */ public class User { private String username; diff --git a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/security/SampleLoginModule.java b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/security/SampleLoginModule.java index dabf2ead1..66516bf5d 100644 --- a/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/security/SampleLoginModule.java +++ b/rest/taskana-rest-spring-example/src/main/java/pro/taskana/rest/security/SampleLoginModule.java @@ -10,9 +10,7 @@ import javax.security.auth.callback.NameCallback; import javax.security.auth.callback.PasswordCallback; import javax.security.auth.spi.LoginModule; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; -import org.springframework.stereotype.Component; import pro.taskana.ldap.LdapCacheTestImpl; import pro.taskana.rest.resource.AccessIdResource; diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/AbstractPagingControllerRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/AbstractPagingControllerRestDocumentation.java index af1a88ac2..c18010893 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/AbstractPagingControllerRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/AbstractPagingControllerRestDocumentation.java @@ -29,31 +29,34 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMv import java.util.HashMap; +/** + * Generate Rest Docu for AbstractPagingController. + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class AbstractPagingControllerRestDocumentation { - + @LocalServerPort int port; - + @Rule public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); - + @Autowired private WebApplicationContext context; - + private MockMvc mockMvc; private HashMap pagingFieldDescriptionsMap = new HashMap(); - + private FieldDescriptor[] pagingFieldDescriptors; - + @Before public void setUp() { document("{methodName}", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint())); - + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) .apply(springSecurity()) .apply(documentationConfiguration(this.restDocumentation) @@ -61,7 +64,7 @@ public class AbstractPagingControllerRestDocumentation { .withResponseDefaults(prettyPrint()) .withRequestDefaults(prettyPrint())) .build(); - + pagingFieldDescriptionsMap.put("page", "Contains metainfo if there are multiple pages, else it is null"); pagingFieldDescriptionsMap.put("page.size", "Number of items per page"); pagingFieldDescriptionsMap.put("page.totalElements", "Total number of items"); @@ -71,10 +74,10 @@ public class AbstractPagingControllerRestDocumentation { pagingFieldDescriptionsMap.put("_links.first.href", "Link to first page"); pagingFieldDescriptionsMap.put("_links.last.href", "Link to last page"); pagingFieldDescriptionsMap.put("_links.prev.href", "Link to previous page"); - pagingFieldDescriptionsMap.put("_links.next.href", "Link to next page"); - + pagingFieldDescriptionsMap.put("_links.next.href", "Link to next page"); + pagingFieldDescriptors = new FieldDescriptor[] { - + subsectionWithPath("_embedded.classificationSummaryResourceList").ignored(), fieldWithPath("_links").ignored(), fieldWithPath("_links.self").ignored(), @@ -91,7 +94,7 @@ public class AbstractPagingControllerRestDocumentation { fieldWithPath("_links.next.href").description(pagingFieldDescriptionsMap.get("_links.next.href")) }; } - + @Test public void commonSummaryResourceFieldsDocTest() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/ClassificationControllerRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/ClassificationControllerRestDocumentation.java index c1f396bce..03baaeb97 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/ClassificationControllerRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/ClassificationControllerRestDocumentation.java @@ -38,7 +38,10 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import pro.taskana.rest.RestConfiguration; - +/** + * Generate REST Dokumentation for ClassificationController. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class ClassificationControllerRestDocumentation { diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/ClassificationDefinitionControllerRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/ClassificationDefinitionControllerRestDocumentation.java index 136e7de1f..f3cc50dac 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/ClassificationDefinitionControllerRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/ClassificationDefinitionControllerRestDocumentation.java @@ -5,7 +5,6 @@ import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.docu import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; import static org.springframework.restdocs.request.RequestDocumentation.partWithName; @@ -33,6 +32,10 @@ import org.springframework.web.context.WebApplicationContext; import pro.taskana.rest.RestConfiguration; +/** + * Test ClassificationDefinitionControlller. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class ClassificationDefinitionControllerRestDocumentation { diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/CommonRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/CommonRestDocumentation.java index a8a4e52f6..5b8feda83 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/CommonRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/CommonRestDocumentation.java @@ -31,6 +31,10 @@ import org.springframework.web.context.WebApplicationContext; import pro.taskana.rest.RestConfiguration; +/** + * Generate common REST Documentation. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class CommonRestDocumentation { diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/MonitorControllerRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/MonitorControllerRestDocumentation.java index f82d98dbd..b16e10ca9 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/MonitorControllerRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/MonitorControllerRestDocumentation.java @@ -30,72 +30,78 @@ import org.springframework.web.context.WebApplicationContext; import pro.taskana.rest.RestConfiguration; +/** + * Generate REST docu for the monitor controller. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class MonitorControllerRestDocumentation { @LocalServerPort int port; - + @Rule public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); - + @Autowired private WebApplicationContext context; - + private MockMvc mockMvc; - + private FieldDescriptor[] taskReportFieldDescriptors; @Before public void setUp() { document("{methodName}", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint())); - + preprocessRequest(prettyPrint()), + preprocessResponse(prettyPrint())); + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(springSecurity()) - .apply(documentationConfiguration(this.restDocumentation) - .operationPreprocessors() - .withResponseDefaults(prettyPrint()) - .withRequestDefaults(prettyPrint())) - .build(); - + .apply(springSecurity()) + .apply(documentationConfiguration(this.restDocumentation) + .operationPreprocessors() + .withResponseDefaults(prettyPrint()) + .withRequestDefaults(prettyPrint())) + .build(); + taskReportFieldDescriptors = new FieldDescriptor[] { - fieldWithPath("meta").description("Object holding metainfo on the report"), - fieldWithPath("meta.name").description("Name of the report"), - fieldWithPath("meta.date").description("Date of the report creation"), - fieldWithPath("meta.header").description("Column-headers of the report"), - fieldWithPath("meta.rowDesc").description("Descriptions for the rows the report"), - fieldWithPath("meta.totalDesc").description("Description for the report itself"), - subsectionWithPath("rows").description("Object holding the rows of the report.\n" - + "For the exact structure please check the example response above"), - fieldWithPath("sumRow").description("Object holding the sums in the columns over all rows"), - subsectionWithPath("sumRow.cells").description("Contains the accumulated numbers over all columns defined in meta.header.\n" - + "For the exact structure please check the example response above"), - fieldWithPath("sumRow.total").description("Total number of tasks"), - fieldWithPath("_links.self.href").ignored() + fieldWithPath("meta").description("Object holding metainfo on the report"), + fieldWithPath("meta.name").description("Name of the report"), + fieldWithPath("meta.date").description("Date of the report creation"), + fieldWithPath("meta.header").description("Column-headers of the report"), + fieldWithPath("meta.rowDesc").description("Descriptions for the rows the report"), + fieldWithPath("meta.totalDesc").description("Description for the report itself"), + subsectionWithPath("rows").description("Object holding the rows of the report.\n" + + "For the exact structure please check the example response above"), + fieldWithPath("sumRow").description("Object holding the sums in the columns over all rows"), + subsectionWithPath("sumRow.cells") + .description("Contains the accumulated numbers over all columns defined in meta.header.\n" + + "For the exact structure please check the example response above"), + fieldWithPath("sumRow.total").description("Total number of tasks"), + fieldWithPath("_links.self.href").ignored() }; } - + @Test public void getTaskStatusReport() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders - .get("http://127.0.0.1:" + port + "/v1/monitor/tasks-status-report") - .header("Authorization", "Basic YWRtaW46YWRtaW4=")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("GetTaskStatusReportDocTest", + .get("http://127.0.0.1:" + port + "/v1/monitor/tasks-status-report") + .header("Authorization", "Basic YWRtaW46YWRtaW4=")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("GetTaskStatusReportDocTest", responseFields(taskReportFieldDescriptors))); } - + @Test public void tasksWorkbasketReport() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders - .get("http://127.0.0.1:" + port + "/v1/monitor/tasks-workbasket-report?daysInPast=4&states=READY,CLAIMED,COMPLETED") - .accept("application/hal+json") - .header("Authorization", "Basic YWRtaW46YWRtaW4=")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("GetTaskWorkbasketReportDocTest", + .get("http://127.0.0.1:" + port + + "/v1/monitor/tasks-workbasket-report?daysInPast=4&states=READY,CLAIMED,COMPLETED") + .accept("application/hal+json") + .header("Authorization", "Basic YWRtaW46YWRtaW4=")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("GetTaskWorkbasketReportDocTest", responseFields(taskReportFieldDescriptors))); } diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/TaskControllerRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/TaskControllerRestDocumentation.java index 7ccdac33b..9a847ccbd 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/TaskControllerRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/TaskControllerRestDocumentation.java @@ -1,5 +1,23 @@ package pro.taskana.doc.api; +import static org.junit.Assert.assertEquals; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.HashMap; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -18,84 +36,84 @@ import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; + import pro.taskana.rest.RestConfiguration; -import static org.junit.Assert.assertEquals; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; -import static org.springframework.restdocs.payload.PayloadDocumentation.*; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; -import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*; -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.HashMap; - +/** + * Generate REST Documentation for the TaskController. + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class TaskControllerRestDocumentation { + @LocalServerPort int port; - + @Rule public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); - + @Autowired private WebApplicationContext context; - + private MockMvc mockMvc; - + private HashMap taskFieldDescriptionsMap = new HashMap(); - + private FieldDescriptor[] allTasksFieldDescriptors; private FieldDescriptor[] taskFieldDescriptors; - private FieldDescriptor[] taskSubsetFieldDescriptors; + private FieldDescriptor[] taskSubsetFieldDescriptors; private FieldDescriptor[] createTaskFieldDescriptors; - + @Before public void setUp() { document("{methodName}", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint())); - + preprocessRequest(prettyPrint()), + preprocessResponse(prettyPrint())); + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(springSecurity()) - .apply(documentationConfiguration(this.restDocumentation) - .operationPreprocessors() - .withResponseDefaults(prettyPrint()) - .withRequestDefaults(prettyPrint())) - .build(); - + .apply(springSecurity()) + .apply(documentationConfiguration(this.restDocumentation) + .operationPreprocessors() + .withResponseDefaults(prettyPrint()) + .withRequestDefaults(prettyPrint())) + .build(); + taskFieldDescriptionsMap.put("taskId", "Unique ID"); - taskFieldDescriptionsMap.put("externalId", "External ID. Can be used to enforce idempotency at task creation. Can identify an external task."); + taskFieldDescriptionsMap.put("externalId", + "External ID. Can be used to enforce idempotency at task creation. Can identify an external task."); taskFieldDescriptionsMap.put("created", "The creation timestamp of the task in the system."); taskFieldDescriptionsMap.put("claimed", "The timestamp of the last claim-operation on the task"); taskFieldDescriptionsMap.put("completed", "The timestamp of the completion of the task"); taskFieldDescriptionsMap.put("modified", "Timestamp of the last modification of the task"); - taskFieldDescriptionsMap.put("planned", "Planned start of the task. The actual completion of the task should be between PLANNED and DUE."); - taskFieldDescriptionsMap.put("due", "Timestamp when the task is due. The actual completion of the task should be between PLANNED and DUE."); + taskFieldDescriptionsMap.put("planned", + "Planned start of the task. The actual completion of the task should be between PLANNED and DUE."); + taskFieldDescriptionsMap.put("due", + "Timestamp when the task is due. The actual completion of the task should be between PLANNED and DUE."); taskFieldDescriptionsMap.put("name", "The name of the task"); taskFieldDescriptionsMap.put("creator", ""); taskFieldDescriptionsMap.put("description", "The description of the task"); taskFieldDescriptionsMap.put("note", "note"); taskFieldDescriptionsMap.put("priority", "The priority of the task"); taskFieldDescriptionsMap.put("state", "he state of the task. See (...)"); - taskFieldDescriptionsMap.put("classificationSummaryResource", "The <> of the task"); + taskFieldDescriptionsMap.put("classificationSummaryResource", + "The <> of the task"); taskFieldDescriptionsMap.put("workbasketSummaryResource", "The <> of the task"); taskFieldDescriptionsMap.put("businessProcessId", ""); taskFieldDescriptionsMap.put("parentBusinessProcessId", ""); taskFieldDescriptionsMap.put("owner", "The owner of the tasks. The owner is set upon claiming of the task."); taskFieldDescriptionsMap.put("primaryObjRef.id", ""); taskFieldDescriptionsMap.put("primaryObjRef.company", "The company referenced primary object belongs to."); - taskFieldDescriptionsMap.put("primaryObjRef.system", "The (kind of) system, the object resides in (e.g. SAP, MySystem A, ...) "); - taskFieldDescriptionsMap.put("primaryObjRef.systemInstance", "The instance of the system, the object resides in."); - taskFieldDescriptionsMap.put("primaryObjRef.type", "The type of the reference (contract, claim, policy, customer, ...)"); + taskFieldDescriptionsMap.put("primaryObjRef.system", + "The (kind of) system, the object resides in (e.g. SAP, MySystem A, ...) "); + taskFieldDescriptionsMap.put("primaryObjRef.systemInstance", + "The instance of the system, the object resides in."); + taskFieldDescriptionsMap.put("primaryObjRef.type", + "The type of the reference (contract, claim, policy, customer, ...)"); taskFieldDescriptionsMap.put("primaryObjRef.value", "The value of the primary object reference"); - taskFieldDescriptionsMap.put("customAttributes", "A container for all additional information on the task in JSON representation"); - taskFieldDescriptionsMap.put("callbackInfo", "A container for all callback information of the task in JSON representation"); + taskFieldDescriptionsMap.put("customAttributes", + "A container for all additional information on the task in JSON representation"); + taskFieldDescriptionsMap.put("callbackInfo", + "A container for all callback information of the task in JSON representation"); taskFieldDescriptionsMap.put("attachments", ""); taskFieldDescriptionsMap.put("custom1", "A custom property with name \"1\""); taskFieldDescriptionsMap.put("custom2", "A custom property with name \"2\""); @@ -115,203 +133,238 @@ public class TaskControllerRestDocumentation { taskFieldDescriptionsMap.put("custom16", "A custom property with name \"16\""); taskFieldDescriptionsMap.put("read", "Indicator if the task has been read"); taskFieldDescriptionsMap.put("transferred", "Indicator if the task has been transferred"); - + allTasksFieldDescriptors = new FieldDescriptor[] { - subsectionWithPath("_embedded.tasks").description("An Array of <>"), - fieldWithPath("_links").ignored(), - fieldWithPath("_links.self").ignored(), - fieldWithPath("_links.self.href").ignored(), - fieldWithPath("page").ignored() + subsectionWithPath("_embedded.tasks").description("An Array of <>"), + fieldWithPath("_links").ignored(), + fieldWithPath("_links.self").ignored(), + fieldWithPath("_links.self.href").ignored(), + fieldWithPath("page").ignored() }; - + taskFieldDescriptors = new FieldDescriptor[] { - - fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")), - fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")), - fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")), - fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String"), - fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"), - fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"), - fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"), - fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), - fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), - fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), - fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")), - fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"), - fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), - fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), - subsectionWithPath("classificationSummaryResource").description(taskFieldDescriptionsMap.get("classificationSummaryResource")), - subsectionWithPath("workbasketSummaryResource").description(taskFieldDescriptionsMap.get("workbasketSummaryResource")), - fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")), - fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), - fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"), - fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String"), - fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), - fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), - fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), - fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), - fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), - fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")), - fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")), - fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")), - fieldWithPath("callbackInfo").description(taskFieldDescriptionsMap.get("callbackInfo")), - fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")), - fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String"), - fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String"), - fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String"), - fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String"), - fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String"), - fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String"), - fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String"), - fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String"), - fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String"), - fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String"), - fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String"), - fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String"), - fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String"), - fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String"), - fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String"), - fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String"), - fieldWithPath("_links.self.href").ignored() + + fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")), + fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")), + fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")), + fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String"), + fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"), + fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"), + fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"), + fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), + fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), + fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), + fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")), + fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"), + fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), + fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), + subsectionWithPath("classificationSummaryResource") + .description(taskFieldDescriptionsMap.get("classificationSummaryResource")), + subsectionWithPath("workbasketSummaryResource") + .description(taskFieldDescriptionsMap.get("workbasketSummaryResource")), + fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")), + fieldWithPath("parentBusinessProcessId") + .description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), + fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"), + fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")) + .type("String"), + fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), + fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), + fieldWithPath("primaryObjRef.systemInstance") + .description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), + fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), + fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), + fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")), + fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")), + fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")), + fieldWithPath("callbackInfo").description(taskFieldDescriptionsMap.get("callbackInfo")), + fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")), + fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String"), + fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String"), + fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String"), + fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String"), + fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String"), + fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String"), + fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String"), + fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String"), + fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String"), + fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String"), + fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String"), + fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String"), + fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String"), + fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String"), + fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String"), + fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String"), + fieldWithPath("_links.self.href").ignored() }; - + taskSubsetFieldDescriptors = new FieldDescriptor[] { - fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")), - fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")), - fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")), - fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")), - fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"), - fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"), - fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"), - fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), - fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), - fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), - fieldWithPath("description").ignored(), - fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"), - fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), - fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), - subsectionWithPath("classificationSummaryResource").description(taskFieldDescriptionsMap.get("classificationSummaryResource")), - subsectionWithPath("workbasketSummaryResource").description(taskFieldDescriptionsMap.get("workbasketSummaryResource")), - fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")), - fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), - fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")), - fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String"), - fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), - fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), - fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), - fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), - fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), - fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")), - fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")), - fieldWithPath("customAttributes").ignored(), - fieldWithPath("callbackInfo").ignored(), - fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")), - fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")), - fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")), - fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")), - fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")), - fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")), - fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")), - fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")), - fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")), - fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")), - fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")), - fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")), - fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")), - fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")), - fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")), - fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")), - fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")), - fieldWithPath("_links.self.href").ignored() + fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")), + fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")), + fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")), + fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")), + fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"), + fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"), + fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"), + fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), + fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), + fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), + fieldWithPath("description").ignored(), + fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"), + fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), + fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), + subsectionWithPath("classificationSummaryResource") + .description(taskFieldDescriptionsMap.get("classificationSummaryResource")), + subsectionWithPath("workbasketSummaryResource") + .description(taskFieldDescriptionsMap.get("workbasketSummaryResource")), + fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")), + fieldWithPath("parentBusinessProcessId") + .description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), + fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")), + fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")) + .type("String"), + fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), + fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), + fieldWithPath("primaryObjRef.systemInstance") + .description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), + fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), + fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), + fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")), + fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")), + fieldWithPath("customAttributes").ignored(), + fieldWithPath("callbackInfo").ignored(), + fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")), + fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")), + fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")), + fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")), + fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")), + fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")), + fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")), + fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")), + fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")), + fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")), + fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")), + fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")), + fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")), + fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")), + fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")), + fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")), + fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")), + fieldWithPath("_links.self.href").ignored() }; - + createTaskFieldDescriptors = new FieldDescriptor[] { - - subsectionWithPath("classificationSummaryResource").description("The new classificationSummaryResource for the task"), - subsectionWithPath("workbasketSummaryResource").description("The new workbasketSummaryResource for the task"), - fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")).type("String").optional(), - fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), - fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), - fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), - fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), - fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), - fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")).type("String").optional(), - fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String").optional(), - fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String").optional(), - fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String").optional(), - fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String").optional(), - fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String").optional(), - fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")).type("String").optional(), - fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")).type("String").optional(), - fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")).type("String").optional(), - fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note").type("String").optional(), - fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")).type("String").optional(), - fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")).type("String").optional(), - fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")).type("String").optional(), - fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")).type("String").optional(), - fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String").optional(), - fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String").optional(), - fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")).type("Object").optional(), - fieldWithPath("callbackInfo").description(taskFieldDescriptionsMap.get("callbackInfo")).type("Object").optional(), - fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")).type("Array").optional(), - fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String").optional(), - fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String").optional(), - fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String").optional(), - fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String").optional(), - fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String").optional(), - fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String").optional(), - fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String").optional(), - fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String").optional(), - fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String").optional(), - fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String").optional(), - fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String").optional(), - fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String").optional(), - fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String").optional(), - fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String").optional(), - fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String").optional(), - fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String").optional(), - fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")).type("Boolean").optional(), - fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")).type("Boolean").optional() + + subsectionWithPath("classificationSummaryResource") + .description("The new classificationSummaryResource for the task"), + subsectionWithPath("workbasketSummaryResource") + .description("The new workbasketSummaryResource for the task"), + fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")) + .type("String") + .optional(), + fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), + fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), + fieldWithPath("primaryObjRef.systemInstance") + .description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), + fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), + fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), + fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")).type("String").optional(), + fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String").optional(), + fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String").optional(), + fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String").optional(), + fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String").optional(), + fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String").optional(), + fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")).type("String").optional(), + fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")).type("String").optional(), + fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")) + .type("String") + .optional(), + fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")) + .description("Some custom Note") + .type("String") + .optional(), + fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")).type("String").optional(), + fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")).type("String").optional(), + fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")) + .type("String") + .optional(), + fieldWithPath("parentBusinessProcessId") + .description(taskFieldDescriptionsMap.get("parentBusinessProcessId")) + .type("String") + .optional(), + fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String").optional(), + fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")) + .type("String") + .optional(), + fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")) + .type("Object") + .optional(), + fieldWithPath("callbackInfo").description(taskFieldDescriptionsMap.get("callbackInfo")) + .type("Object") + .optional(), + fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")) + .type("Array") + .optional(), + fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String").optional(), + fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String").optional(), + fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String").optional(), + fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String").optional(), + fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String").optional(), + fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String").optional(), + fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String").optional(), + fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String").optional(), + fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String").optional(), + fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String").optional(), + fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String").optional(), + fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String").optional(), + fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String").optional(), + fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String").optional(), + fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String").optional(), + fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String").optional(), + fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")).type("Boolean").optional(), + fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")) + .type("Boolean") + .optional() }; } - + @Test public void getAllTasksDocTest() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders - .get("http://127.0.0.1:" + port + "/v1/tasks?por.type=VNR&por.value=22334455") - .accept("application/hal+json") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("GetAllTasksDocTest", + .get("http://127.0.0.1:" + port + "/v1/tasks?por.type=VNR&por.value=22334455") + .accept("application/hal+json") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("GetAllTasksDocTest", responseFields(allTasksFieldDescriptors))); } - + @Test public void getSpecificTaskDocTest() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders - .get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000") - .accept("application/hal+json") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("GetSpecificTaskDocTest", + .get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000") + .accept("application/hal+json") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("GetSpecificTaskDocTest", responseFields(taskFieldDescriptors))); } - + @Test public void taskSubSetDocTest() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders - .get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000") - .accept("application/hal+json") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("TaskSubset", + .get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000") + .accept("application/hal+json") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("TaskSubset", responseFields(taskSubsetFieldDescriptors))); } - + @Test - public void updateTaskDocTest() throws Exception{ + public void updateTaskDocTest() throws Exception { URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); con.setRequestMethod("GET"); @@ -330,134 +383,135 @@ public class TaskControllerRestDocumentation { String originalTask = content.toString(); this.mockMvc.perform(RestDocumentationRequestBuilders - .put("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") - .contentType("application/json") - .content(originalTask)) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("UpdateTaskDocTest", + .put("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") + .contentType("application/json") + .content(originalTask)) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("UpdateTaskDocTest", requestFields(taskFieldDescriptors), responseFields(taskFieldDescriptors))); } - + @Test public void createAndDeleteTaskDocTest() throws Exception { - + MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders - .post("http://127.0.0.1:" + port + "/v1/tasks") - .contentType("application/hal+json") - .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + - "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + - "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isCreated()) - .andDo(MockMvcRestDocumentation.document("CreateTaskDocTest", + .post("http://127.0.0.1:" + port + "/v1/tasks") + .contentType("application/hal+json") + .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isCreated()) + .andDo(MockMvcRestDocumentation.document("CreateTaskDocTest", requestFields(createTaskFieldDescriptors), responseFields(taskFieldDescriptors))) - .andReturn(); - + .andReturn(); + String content = result.getResponse().getContentAsString(); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); - + this.mockMvc.perform(RestDocumentationRequestBuilders - .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) - .header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin - .andExpect(MockMvcResultMatchers.status().isNoContent()) - .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); + .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) + .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin + .andExpect(MockMvcResultMatchers.status().isNoContent()) + .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); } - + @Test public void claimTaskDocTest() throws Exception { - + MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders - .post("http://127.0.0.1:" + port + "/v1/tasks") - .contentType("application/hal+json") - .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + - "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + - "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isCreated()) - .andDo(MockMvcRestDocumentation.document("temp")) - .andReturn(); - + .post("http://127.0.0.1:" + port + "/v1/tasks") + .contentType("application/hal+json") + .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isCreated()) + .andDo(MockMvcRestDocumentation.document("temp")) + .andReturn(); + String content = result.getResponse().getContentAsString(); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); - + this.mockMvc.perform(RestDocumentationRequestBuilders - .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/claim") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") - .contentType("application/json") - .content("\"userName\":\"teamlead_1\"")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("ClaimTaskDocTest", + .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/claim") + .accept("application/hal+json") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") + .content("{}")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("ClaimTaskDocTest", responseFields(taskFieldDescriptors))); - + this.mockMvc.perform(RestDocumentationRequestBuilders - .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) - .header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin - .andExpect(MockMvcResultMatchers.status().isNoContent()) - .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); + .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) + .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin + .andExpect(MockMvcResultMatchers.status().isNoContent()) + .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); } - + @Test public void completeTaskDocTest() throws Exception { MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders - .post("http://127.0.0.1:" + port + "/v1/tasks") - .contentType("application/hal+json") - .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + - "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + - "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isCreated()) - .andDo(MockMvcRestDocumentation.document("temp")) - .andReturn(); - + .post("http://127.0.0.1:" + port + "/v1/tasks") + .contentType("application/hal+json") + .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isCreated()) + .andDo(MockMvcRestDocumentation.document("temp")) + .andReturn(); + String content = result.getResponse().getContentAsString(); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); - + this.mockMvc.perform(RestDocumentationRequestBuilders - .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/complete") - .accept("application/hal+json") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") - .content("{}")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("CompleteTaskDocTest", + .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/complete") + .accept("application/hal+json") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") + .content("{}")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("CompleteTaskDocTest", responseFields(taskFieldDescriptors))); - + this.mockMvc.perform(RestDocumentationRequestBuilders - .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) - .header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin - .andExpect(MockMvcResultMatchers.status().isNoContent()) - .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); + .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) + .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin + .andExpect(MockMvcResultMatchers.status().isNoContent()) + .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); } - + @Test public void transferTaskDocTest() throws Exception { MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders - .post("http://127.0.0.1:" + port + "/v1/tasks") - .contentType("application/hal+json") - .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + - "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + - "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isCreated()) - .andDo(MockMvcRestDocumentation.document("TransferTaskDocTest", + .post("http://127.0.0.1:" + port + "/v1/tasks") + .contentType("application/hal+json") + .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isCreated()) + .andDo(MockMvcRestDocumentation.document("TransferTaskDocTest", responseFields(taskFieldDescriptors))) - .andReturn(); - + .andReturn(); + String content = result.getResponse().getContentAsString(); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); - + this.mockMvc.perform(RestDocumentationRequestBuilders - .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/transfer/WBI:100000000000000000000000000000000001") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("TransferTaskDocTest", + .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + + "/transfer/WBI:100000000000000000000000000000000001") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("TransferTaskDocTest", responseFields(taskFieldDescriptors))); - + this.mockMvc.perform(RestDocumentationRequestBuilders - .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) - .header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin - .andExpect(MockMvcResultMatchers.status().isNoContent()); + .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) + .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin + .andExpect(MockMvcResultMatchers.status().isNoContent()); } } diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/TaskanaEngineControllerRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/TaskanaEngineControllerRestDocumentation.java index a00157151..55b7133fc 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/TaskanaEngineControllerRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/TaskanaEngineControllerRestDocumentation.java @@ -29,99 +29,104 @@ import org.springframework.web.context.WebApplicationContext; import pro.taskana.rest.RestConfiguration; +/** + * Generate REST Docu for the TaskanaEngineController. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class TaskanaEngineControllerRestDocumentation { + @LocalServerPort int port; - + @Rule public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); - + @Autowired private WebApplicationContext context; - + private MockMvc mockMvc; - + private FieldDescriptor[] allDomainsFieldDescriptors; private FieldDescriptor[] allClassificationCategoriesFieldDescriptors; private FieldDescriptor[] allClassificationTypesFieldDescriptors; private FieldDescriptor[] currentUserInfoFieldDescriptors; - + @Before public void setUp() { document("{methodName}", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint())); - + preprocessRequest(prettyPrint()), + preprocessResponse(prettyPrint())); + this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(springSecurity()) - .apply(documentationConfiguration(this.restDocumentation) - .operationPreprocessors() - .withResponseDefaults(prettyPrint()) - .withRequestDefaults(prettyPrint())) - .build(); - + .apply(springSecurity()) + .apply(documentationConfiguration(this.restDocumentation) + .operationPreprocessors() + .withResponseDefaults(prettyPrint()) + .withRequestDefaults(prettyPrint())) + .build(); + allDomainsFieldDescriptors = new FieldDescriptor[] { - fieldWithPath("[]").description("An array with the domain-names as strings") + fieldWithPath("[]").description("An array with the domain-names as strings") }; - + allClassificationCategoriesFieldDescriptors = new FieldDescriptor[] { - fieldWithPath("[]").description("An array with the classification-categories as strings") + fieldWithPath("[]").description("An array with the classification-categories as strings") }; - + allClassificationTypesFieldDescriptors = new FieldDescriptor[] { - fieldWithPath("[]").description("An array with the classification-types as strings") + fieldWithPath("[]").description("An array with the classification-types as strings") }; - + currentUserInfoFieldDescriptors = new FieldDescriptor[] { - fieldWithPath("userId").description("Id of the current user"), - fieldWithPath("groupIds").description("An array with the groups the current user is part of as strings"), - fieldWithPath("roles").description("An array with the roles the current user is granted") + fieldWithPath("userId").description("Id of the current user"), + fieldWithPath("groupIds").description("An array with the groups the current user is part of as strings"), + fieldWithPath("roles").description("An array with the roles the current user is granted") }; } - + @Test public void getAllDomainsDocTest() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders - .get("http://127.0.0.1:" + port + "/v1/domains") - .accept("application/json") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("GetAllDomainsDocTest", + .get("http://127.0.0.1:" + port + "/v1/domains") + .accept("application/json") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("GetAllDomainsDocTest", responseFields(allDomainsFieldDescriptors))); } - + @Test public void getAllClassificationCategoriesDocTest() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders - .get("http://127.0.0.1:" + port + "/v1/classification-categories") - .accept("application/json") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("GetAllClassificationCategoriesDocTest", + .get("http://127.0.0.1:" + port + "/v1/classification-categories") + .accept("application/json") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("GetAllClassificationCategoriesDocTest", responseFields(allClassificationCategoriesFieldDescriptors))); } - + @Test public void getAllClassificationTypesDocTest() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders - .get("http://127.0.0.1:" + port + "/v1/classification-types") - .accept("application/json") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("GetAllClassificationTypesDocTest", + .get("http://127.0.0.1:" + port + "/v1/classification-types") + .accept("application/json") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("GetAllClassificationTypesDocTest", responseFields(allClassificationTypesFieldDescriptors))); } - + @Test public void getCurrentUserInfo() throws Exception { this.mockMvc.perform(RestDocumentationRequestBuilders - .get("http://127.0.0.1:" + port + "/v1/current-user-info") - .accept("application/json") - .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("GetCurrentUserInfoDocTest", + .get("http://127.0.0.1:" + port + "/v1/current-user-info") + .accept("application/json") + .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("GetCurrentUserInfoDocTest", responseFields(currentUserInfoFieldDescriptors))); } } diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketAccessItemControllerRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketAccessItemControllerRestDocumentation.java index 9a61a665b..8b4c36722 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketAccessItemControllerRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketAccessItemControllerRestDocumentation.java @@ -1,5 +1,16 @@ package pro.taskana.doc.api; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; +import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; +import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; + +import java.util.HashMap; + import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -16,22 +27,16 @@ import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; + import pro.taskana.rest.RestConfiguration; -import java.util.HashMap; - -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; -import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; -import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; -import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; -import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; -import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; - +/** + * Generate REST Docu for the WorkbasketAccessItemController. + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class WorkbasketAccessItemControllerRestDocumentation { + @LocalServerPort int port; @@ -49,27 +54,33 @@ public class WorkbasketAccessItemControllerRestDocumentation { @Before public void setUp() { document("{methodName}", - preprocessRequest(prettyPrint()), - preprocessResponse(prettyPrint())); + preprocessRequest(prettyPrint()), + preprocessResponse(prettyPrint())); this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) .apply(springSecurity()) .apply(documentationConfiguration(this.restDocumentation) - .operationPreprocessors() - .withResponseDefaults(prettyPrint()) - .withRequestDefaults(prettyPrint())) + .operationPreprocessors() + .withResponseDefaults(prettyPrint()) + .withRequestDefaults(prettyPrint())) .build(); accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessItemId", "Unique ID"); accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketId", "The workbasket id"); - accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId", "The access id. This could be either a userid or a full qualified group id"); + accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessId", + "The access id. This could be either a userid or a full qualified group id"); accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessName", "The name"); accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketKey", "The workbasket key"); - accessItemFieldDescriptionsMap.put("_embedded.accessItems.permRead", "The permission to read the information about the workbasket"); - accessItemFieldDescriptionsMap.put("_embedded.accessItems.permOpen", "The permission to view the content (the tasks) of a workbasket"); - accessItemFieldDescriptionsMap.put("_embedded.accessItems.permAppend", "The permission to add tasks to the workbasket (required for creation and tranferring of tasks)"); - accessItemFieldDescriptionsMap.put("_embedded.accessItems.permTransfer", "The permission to transfer tasks (out of the current workbasket)"); - accessItemFieldDescriptionsMap.put("_embedded.accessItems.permDistribute", "The permission to distribute tasks from the workbasket"); + accessItemFieldDescriptionsMap.put("_embedded.accessItems.permRead", + "The permission to read the information about the workbasket"); + accessItemFieldDescriptionsMap.put("_embedded.accessItems.permOpen", + "The permission to view the content (the tasks) of a workbasket"); + accessItemFieldDescriptionsMap.put("_embedded.accessItems.permAppend", + "The permission to add tasks to the workbasket (required for creation and tranferring of tasks)"); + accessItemFieldDescriptionsMap.put("_embedded.accessItems.permTransfer", + "The permission to transfer tasks (out of the current workbasket)"); + accessItemFieldDescriptionsMap.put("_embedded.accessItems.permDistribute", + "The permission to distribute tasks from the workbasket"); accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom1", ""); accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom2", ""); accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom3", ""); @@ -86,28 +97,50 @@ public class WorkbasketAccessItemControllerRestDocumentation { accessItemFieldDescriptionsMap.put("page", "Number of page"); accessItemFieldDescriptors = new FieldDescriptor[] { - fieldWithPath("_embedded.accessItems[].accessItemId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")), - fieldWithPath("_embedded.accessItems[].workbasketId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")), - fieldWithPath("_embedded.accessItems[].accessId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")), - fieldWithPath("_embedded.accessItems[].accessName").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")), - fieldWithPath("_embedded.accessItems[].workbasketKey").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketKey")), - fieldWithPath("_embedded.accessItems[].permRead").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")), - fieldWithPath("_embedded.accessItems[].permOpen").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")), - fieldWithPath("_embedded.accessItems[].permAppend").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")), - fieldWithPath("_embedded.accessItems[].permTransfer").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")), - fieldWithPath("_embedded.accessItems[].permDistribute").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")), - fieldWithPath("_embedded.accessItems[].permCustom1").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom1")), - fieldWithPath("_embedded.accessItems[].permCustom2").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom2")), - fieldWithPath("_embedded.accessItems[].permCustom3").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom3")), - fieldWithPath("_embedded.accessItems[].permCustom4").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom4")), - fieldWithPath("_embedded.accessItems[].permCustom5").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom5")), - fieldWithPath("_embedded.accessItems[].permCustom6").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom6")), - fieldWithPath("_embedded.accessItems[].permCustom7").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom7")), - fieldWithPath("_embedded.accessItems[].permCustom8").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom8")), - fieldWithPath("_embedded.accessItems[].permCustom9").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom9")), - fieldWithPath("_embedded.accessItems[].permCustom10").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom10")), - fieldWithPath("_embedded.accessItems[].permCustom11").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")), - fieldWithPath("_embedded.accessItems[].permCustom12").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")), + fieldWithPath("_embedded.accessItems[].accessItemId") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")), + fieldWithPath("_embedded.accessItems[].workbasketId") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")), + fieldWithPath("_embedded.accessItems[].accessId") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")), + fieldWithPath("_embedded.accessItems[].accessName") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")), + fieldWithPath("_embedded.accessItems[].workbasketKey") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketKey")), + fieldWithPath("_embedded.accessItems[].permRead") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")), + fieldWithPath("_embedded.accessItems[].permOpen") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")), + fieldWithPath("_embedded.accessItems[].permAppend") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")), + fieldWithPath("_embedded.accessItems[].permTransfer") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")), + fieldWithPath("_embedded.accessItems[].permDistribute") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")), + fieldWithPath("_embedded.accessItems[].permCustom1") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom1")), + fieldWithPath("_embedded.accessItems[].permCustom2") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom2")), + fieldWithPath("_embedded.accessItems[].permCustom3") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom3")), + fieldWithPath("_embedded.accessItems[].permCustom4") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom4")), + fieldWithPath("_embedded.accessItems[].permCustom5") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom5")), + fieldWithPath("_embedded.accessItems[].permCustom6") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom6")), + fieldWithPath("_embedded.accessItems[].permCustom7") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom7")), + fieldWithPath("_embedded.accessItems[].permCustom8") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom8")), + fieldWithPath("_embedded.accessItems[].permCustom9") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom9")), + fieldWithPath("_embedded.accessItems[].permCustom10") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom10")), + fieldWithPath("_embedded.accessItems[].permCustom11") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")), + fieldWithPath("_embedded.accessItems[].permCustom12") + .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")), fieldWithPath("_links.self.href").description(accessItemFieldDescriptionsMap.get("_links.self.href")), fieldWithPath("page").description(accessItemFieldDescriptionsMap.get("page")) }; @@ -115,19 +148,24 @@ public class WorkbasketAccessItemControllerRestDocumentation { @Test public void getWorkbasketAccessItemsDocTest() throws Exception { - this.mockMvc.perform(RestDocumentationRequestBuilders.get("http://127.0.0.1:" + port + "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&access-ids=user_1_1") + this.mockMvc + .perform(RestDocumentationRequestBuilders + .get("http://127.0.0.1:" + port + + "/v1/workbasket-access-items/?sort-by=workbasket-key&order=asc&access-ids=user_1_1") .accept("application/hal+json") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isOk()) - .andDo(MockMvcRestDocumentation.document("GetWorkbasketAccessItemsDocTest", - responseFields(accessItemFieldDescriptors))); + .andExpect(MockMvcResultMatchers.status().isOk()) + .andDo(MockMvcRestDocumentation.document("GetWorkbasketAccessItemsDocTest", + responseFields(accessItemFieldDescriptors))); } @Test public void removeWorkbasketAccessItemsDocTest() throws Exception { - this.mockMvc.perform(RestDocumentationRequestBuilders.delete("http://127.0.0.1:" + port + "/v1/workbasket-access-items/?access-id=user_1_1") + this.mockMvc + .perform(RestDocumentationRequestBuilders + .delete("http://127.0.0.1:" + port + "/v1/workbasket-access-items/?access-id=user_1_1") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) - .andExpect(MockMvcResultMatchers.status().isNoContent()) - .andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest")); + .andExpect(MockMvcResultMatchers.status().isNoContent()) + .andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest")); } } diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketControllerRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketControllerRestDocumentation.java index 1954c508d..84ce2b7fa 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketControllerRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketControllerRestDocumentation.java @@ -38,6 +38,9 @@ import org.springframework.web.context.WebApplicationContext; import pro.taskana.rest.RestConfiguration; +/** + * Generate REST Documentatioon for the WorkbasketController. + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class WorkbasketControllerRestDocumentation { @@ -53,7 +56,7 @@ public class WorkbasketControllerRestDocumentation { private MockMvc mockMvc; - // HashMaps to store the field descriptions centrally for multiple uses + // HashMaps to store the field descriptions centrally for multiple uses private HashMap workbasketFieldDescriptionsMap = new HashMap(); private HashMap accessItemFieldDescriptionsMap = new HashMap(); @@ -269,28 +272,39 @@ public class WorkbasketControllerRestDocumentation { fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")), fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")), fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")).type("String").optional(), fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("created").description(workbasketFieldDescriptionsMap.get("created")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("modified").description(workbasketFieldDescriptionsMap.get("modified")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")) - .type("String").optional(), + .type("String") + .optional(), fieldWithPath("_links.distributionTargets.href").description( workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")).type("String").optional(), fieldWithPath("_links.removeDistributionTargets.href").description( diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketDefinitionControllerRestDocumentation.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketDefinitionControllerRestDocumentation.java index 4970bfe46..2f0373f27 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketDefinitionControllerRestDocumentation.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/doc/api/WorkbasketDefinitionControllerRestDocumentation.java @@ -5,7 +5,6 @@ import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.docu import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; -import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; import static org.springframework.restdocs.request.RequestDocumentation.partWithName; @@ -33,6 +32,10 @@ import org.springframework.web.context.WebApplicationContext; import pro.taskana.rest.RestConfiguration; +/** + * Generate Rest Documentation for Workbasket Definitions. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class WorkbasketDefinitionControllerRestDocumentation { @@ -96,7 +99,6 @@ public class WorkbasketDefinitionControllerRestDocumentation { .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .andExpect(MockMvcResultMatchers.status().isOk()) .andDo(document("ImportWorkbasketDefinitions", requestParts( - partWithName("file").description("The file to upload")) - )); + partWithName("file").description("The file to upload")))); } -} \ No newline at end of file +} diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/historyPlugin/HistoryPluginLoaderTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/historyPlugin/HistoryPluginLoaderTest.java index 7241ac9c5..922e2cde2 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/historyPlugin/HistoryPluginLoaderTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/historyPlugin/HistoryPluginLoaderTest.java @@ -17,6 +17,10 @@ import pro.taskana.history.HistoryEventProducer; import pro.taskana.impl.TaskanaEngineImpl; import pro.taskana.rest.RestConfiguration; +/** + * test loading of history plugin. + * + */ @RunWith(SpringRunner.class) @ActiveProfiles(profiles = "history.plugin") @SpringBootTest(classes = RestConfiguration.class) diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/jobs/AsyncUpdateJobIntTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/jobs/AsyncUpdateJobIntTest.java index 3ff1d8ba0..01b22a436 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/jobs/AsyncUpdateJobIntTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/jobs/AsyncUpdateJobIntTest.java @@ -46,10 +46,13 @@ import pro.taskana.Task; import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.resource.ClassificationResource; -import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.ClassificationResourceAssembler; +import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.TaskResourceAssembler; +/** + * Test async updates. + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) @@ -121,7 +124,8 @@ public class AsyncUpdateJobIntTest { long delay = 16000; - LOGGER.info("About to sleep for {} seconds to give JobScheduler a chance to process the classification change", delay / 1000); + LOGGER.info("About to sleep for {} seconds to give JobScheduler a chance to process the classification change", + delay / 1000); Thread.sleep(delay); LOGGER.info("Sleeping ended. Continuing .... "); @@ -188,7 +192,7 @@ public class AsyncUpdateJobIntTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ @@ -201,7 +205,7 @@ public class AsyncUpdateJobIntTest { converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); converter.setObjectMapper(mapper); - RestTemplate template = new RestTemplate(Collections.>singletonList(converter)); + RestTemplate template = new RestTemplate(Collections.> singletonList(converter)); return template; } diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/ldap/LdapTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/ldap/LdapTest.java index a192d4362..49074ed43 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/ldap/LdapTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/ldap/LdapTest.java @@ -17,6 +17,10 @@ import pro.taskana.impl.util.LoggerUtils; import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.resource.AccessIdResource; +/** + * Test Ldap attachment. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) @ContextConfiguration(classes = {RestConfiguration.class}) diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/AccessIdValidationControllerTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/AccessIdValidationControllerTest.java index f12adf136..a7a2a9a3d 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/AccessIdValidationControllerTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/AccessIdValidationControllerTest.java @@ -14,7 +14,6 @@ import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.context.annotation.Import; import org.springframework.core.ParameterizedTypeReference; import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.http.HttpEntity; @@ -35,6 +34,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import pro.taskana.ldap.LdapCacheTestImpl; import pro.taskana.rest.resource.AccessIdResource; +/** + * Test AccessIdValidation. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "devMode=true"}) @@ -85,7 +88,7 @@ public class AccessIdValidationControllerTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/ClassificationControllerIntTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/ClassificationControllerIntTest.java index 32f543b55..985607f7e 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/ClassificationControllerIntTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/ClassificationControllerIntTest.java @@ -15,8 +15,6 @@ import java.util.Collections; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; @@ -45,24 +43,24 @@ import pro.taskana.Task; import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.rest.resource.ClassificationSummaryResource; import pro.taskana.rest.resource.TaskResource; -import pro.taskana.rest.resource.ClassificationResourceAssembler; import pro.taskana.rest.resource.TaskResourceAssembler; +/** + * Test ClassificationController. + * @author bbr + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) public class ClassificationControllerIntTest { - @Autowired - private ClassificationResourceAssembler classificationResourceAssembler; - - @Autowired + @Autowired private TaskResourceAssembler taskResourceAssembler; @Autowired Environment env; - private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationControllerIntTest.class); String server = "http://127.0.0.1:"; RestTemplate template; HttpEntity request; @@ -342,7 +340,7 @@ public class ClassificationControllerIntTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/ClassificationDefinitionControllerIntTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/ClassificationDefinitionControllerIntTest.java index a7b18313f..dc39b4015 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/ClassificationDefinitionControllerIntTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/ClassificationDefinitionControllerIntTest.java @@ -46,6 +46,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationSummaryResource; +/** + * Test classification definitions. + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = { "devMode=true"}) @@ -65,33 +68,31 @@ public class ClassificationDefinitionControllerIntTest { @Before public void before() { - LOGGER.debug("before"); + LOGGER.debug("before"); template = getRestTemplate(); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); request = new HttpEntity(headers); } - @Test + @Test public void testExportClassifications() { ResponseEntity response = template.exchange( - server + port + "/v1/classification-definitions?domain=DOMAIN_B", - HttpMethod.GET, request, new ParameterizedTypeReference() { - } - ); + server + port + "/v1/classification-definitions?domain=DOMAIN_B", + HttpMethod.GET, request, new ParameterizedTypeReference() { + }); assertEquals(HttpStatus.OK, response.getStatusCode()); assertTrue(response.getBody().length >= 5); assertTrue(response.getBody().length <= 7); } - @Test - public void testExportClassificationsFromWrongDomain() { + @Test + public void testExportClassificationsFromWrongDomain() { ResponseEntity response = template.exchange( - server + port + "/v1/classification-definitions?domain=ADdfe", - HttpMethod.GET, request, new ParameterizedTypeReference() { - } - ); + server + port + "/v1/classification-definitions?domain=ADdfe", + HttpMethod.GET, request, new ParameterizedTypeReference() { + }); assertEquals(0, response.getBody().length); - } + } @Test public void testImportFilledClassification() throws IOException { @@ -150,7 +151,7 @@ public class ClassificationDefinitionControllerIntTest { try { importRequest(clList); - } catch(HttpClientErrorException e) { + } catch (HttpClientErrorException e) { assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); } } @@ -164,7 +165,7 @@ public class ClassificationDefinitionControllerIntTest { try { importRequest(clList); - } catch(HttpClientErrorException e) { + } catch (HttpClientErrorException e) { assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); } } @@ -173,8 +174,9 @@ public class ClassificationDefinitionControllerIntTest { public void testImportMultipleClassifications() throws IOException { ClassificationResource classification1 = this.createClassification("id1", "ImportKey1", "DOMAIN_A", null, null); String c1 = objMapper.writeValueAsString(classification1); - - ClassificationResource classification2 = this.createClassification("id2", "ImportKey2", "DOMAIN_A", "CLI:100000000000000000000000000000000016", "T2000"); + + ClassificationResource classification2 = this.createClassification("id2", "ImportKey2", "DOMAIN_A", + "CLI:100000000000000000000000000000000016", "T2000"); classification2.setCategory("MANUAL"); classification2.setType("TASK"); classification2.setIsValidInDomain(true); @@ -223,15 +225,16 @@ public class ClassificationDefinitionControllerIntTest { ResponseEntity response = importRequest(clList); assertEquals(HttpStatus.OK, response.getStatusCode()); - + existingClassification.setName("second new Name"); clList = new ArrayList<>(); clList.add(objMapper.writeValueAsString(existingClassification)); response = importRequest(clList); assertEquals(HttpStatus.OK, response.getStatusCode()); - - ClassificationSummaryResource testClassification = this.getClassificationWithKeyAndDomain("L110107", "DOMAIN_A"); + + ClassificationSummaryResource testClassification = this.getClassificationWithKeyAndDomain("L110107", + "DOMAIN_A"); assertEquals("second new Name", testClassification.getName()); } @@ -249,7 +252,7 @@ public class ClassificationDefinitionControllerIntTest { ResponseEntity response = importRequest(clList); assertEquals(HttpStatus.OK, response.getStatusCode()); - + ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("L11010", "DOMAIN_A"); ClassificationSummaryResource testNewCl = getClassificationWithKeyAndDomain("newClass", "DOMAIN_A"); ClassificationSummaryResource testExistingCl = getClassificationWithKeyAndDomain("L110102", "DOMAIN_A"); @@ -263,15 +266,18 @@ public class ClassificationDefinitionControllerIntTest { @Test public void testImportParentAndChildClassification() throws IOException { - ClassificationResource classification1 = this.createClassification("parentId", "ImportKey6", "DOMAIN_A", null, null); + ClassificationResource classification1 = this.createClassification("parentId", "ImportKey6", "DOMAIN_A", null, + null); String c1 = objMapper.writeValueAsString(classification1); - - ClassificationResource classification2 = this.createClassification("childId1", "ImportKey7", "DOMAIN_A", null, "ImportKey6"); + + ClassificationResource classification2 = this.createClassification("childId1", "ImportKey7", "DOMAIN_A", null, + "ImportKey6"); String c21 = objMapper.writeValueAsString(classification2); classification2 = this.createClassification("childId2", "ImportKey8", "DOMAIN_A", "parentId", null); String c22 = objMapper.writeValueAsString(classification2); - ClassificationResource classification3 = this.createClassification("grandchildId1", "ImportKey9", "DOMAIN_A", "childId1", "ImportKey7"); + ClassificationResource classification3 = this.createClassification("grandchildId1", "ImportKey9", "DOMAIN_A", + "childId1", "ImportKey7"); String c31 = objMapper.writeValueAsString(classification3); classification3 = this.createClassification("grandchild2", "ImportKey10", "DOMAIN_A", null, "ImportKey7"); String c32 = objMapper.writeValueAsString(classification3); @@ -285,7 +291,6 @@ public class ClassificationDefinitionControllerIntTest { ResponseEntity response = importRequest(clList); assertEquals(HttpStatus.OK, response.getStatusCode()); - ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A"); ClassificationSummaryResource childCl = getClassificationWithKeyAndDomain("ImportKey7", "DOMAIN_A"); @@ -303,9 +308,11 @@ public class ClassificationDefinitionControllerIntTest { ClassificationResource classification1 = createClassification("parent", "ImportKey11", "DOMAIN_A", null, null); classification1.setCustom1("parent is correct"); String parent = objMapper.writeValueAsString(classification1); - ClassificationResource classification2 = createClassification("wrongParent", "ImportKey11", "DOMAIN_B", null, null); + ClassificationResource classification2 = createClassification("wrongParent", "ImportKey11", "DOMAIN_B", null, + null); String wrongParent = objMapper.writeValueAsString(classification2); - ClassificationResource classification3 = createClassification("child", "ImportKey13", "DOMAIN_A", null, "ImportKey11"); + ClassificationResource classification3 = createClassification("child", "ImportKey13", "DOMAIN_A", null, + "ImportKey11"); String child = objMapper.writeValueAsString(classification3); List clList = new ArrayList<>(); @@ -327,7 +334,8 @@ public class ClassificationDefinitionControllerIntTest { assertNotEquals(wrongParentCl.getClassificationId(), childCl.getParentId()); } - private ClassificationResource createClassification(String id, String key, String domain, String parentId, String parentKey) { + private ClassificationResource createClassification(String id, String key, String domain, String parentId, + String parentKey) { ClassificationResource classificationResource = new ClassificationResource(); classificationResource.setClassificationId(id); classificationResource.setKey(key); @@ -353,18 +361,18 @@ public class ClassificationDefinitionControllerIntTest { return response.getBody().getContent().toArray(new ClassificationSummaryResource[1])[0]; } - private ResponseEntity importRequest (List clList) throws IOException { + private ResponseEntity importRequest(List clList) throws IOException { LOGGER.debug("Start Import"); File tmpFile = File.createTempFile("test", ".tmp"); FileWriter writer = new FileWriter(tmpFile); writer.write(clList.toString()); - writer.close(); + writer.close(); MultiValueMap body = new LinkedMultiValueMap<>(); headers.setContentType(MediaType.MULTIPART_FORM_DATA); body.add("file", new FileSystemResource(tmpFile)); - HttpEntity> requestEntity = new HttpEntity<>(body, headers); + HttpEntity> requestEntity = new HttpEntity<>(body, headers); String serverUrl = server + port + "/v1/classification-definitions"; RestTemplate restTemplate = new RestTemplate(); @@ -372,7 +380,7 @@ public class ClassificationDefinitionControllerIntTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ @@ -385,7 +393,7 @@ public class ClassificationDefinitionControllerIntTest { converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/haljson,*/*")); converter.setObjectMapper(mapper); - RestTemplate template = new RestTemplate(Collections.>singletonList(converter)); + RestTemplate template = new RestTemplate(Collections.> singletonList(converter)); return template; } } diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/GenenalExceptionHandlingTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/GenenalExceptionHandlingTest.java index 1a45f3ab0..5796c0ac0 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/GenenalExceptionHandlingTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/GenenalExceptionHandlingTest.java @@ -13,11 +13,7 @@ import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; - -import ch.qos.logback.classic.Logger; - import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.core.ParameterizedTypeReference; @@ -35,25 +31,22 @@ import org.springframework.web.client.RestTemplate; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import ch.qos.logback.classic.Logger; import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.core.Appender; import pro.taskana.ldap.LdapCacheTestImpl; import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.ClassificationSummaryResource; -import pro.taskana.rest.resource.ClassificationResourceAssembler; -import pro.taskana.rest.resource.TaskResourceAssembler; +/** + * Test general Exception Handling. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "devMode=true"}) public class GenenalExceptionHandlingTest { - @Autowired - private ClassificationResourceAssembler classificationResourceAssembler; - - @Autowired - private TaskResourceAssembler taskResourceAssembler; - String server = "http://127.0.0.1:"; RestTemplate template; HttpEntity request; @@ -118,7 +111,7 @@ public class GenenalExceptionHandlingTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TaskControllerIntTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TaskControllerIntTest.java index eea6c97bd..d3d0112a8 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TaskControllerIntTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TaskControllerIntTest.java @@ -50,6 +50,9 @@ import pro.taskana.exceptions.SystemException; import pro.taskana.rest.resource.TaskSummaryResource; import pro.taskana.sampledata.SampleDataGenerator; +/** + * Test Task Controller. + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) @@ -374,9 +377,9 @@ public class TaskControllerIntTest { @Test public void testCreateAndDeleteTask() throws IOException { - String taskToCreateJson = "{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + - "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + - "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; + String taskToCreateJson = "{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); @@ -400,9 +403,9 @@ public class TaskControllerIntTest { } in.close(); con.disconnect(); - String createdTask = responsePayload.toString(); + String createdTask = responsePayload.toString(); String taskIdOfCreatedTask = createdTask.substring(createdTask.indexOf("TKI:"), createdTask.indexOf("TKI:") + 40); - + assertNotNull(taskIdOfCreatedTask); assertTrue(taskIdOfCreatedTask.startsWith("TKI:")); @@ -417,9 +420,9 @@ public class TaskControllerIntTest { @Test public void testCreateTaskWithInvalidParameter() throws IOException { - String taskToCreateJson = "{\"classificationKey\":\"L11010\"," + - "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + - "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; + String taskToCreateJson = "{\"classificationKey\":\"L11010\"," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks"); HttpURLConnection con = (HttpURLConnection) url.openConnection(); @@ -434,11 +437,9 @@ public class TaskControllerIntTest { assertEquals(400, con.getResponseCode()); con.disconnect(); - taskToCreateJson = - "{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"}," - + - "\"workbasketSummaryResource\":{\"workbasketId\":\"\"}," + - "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; + taskToCreateJson = "{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"\"}," + + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; url = new URL("http://127.0.0.1:" + port + "/v1/tasks"); con = (HttpURLConnection) url.openConnection(); @@ -456,7 +457,7 @@ public class TaskControllerIntTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ @@ -470,7 +471,7 @@ public class TaskControllerIntTest { // converter.setSupportedMediaTypes(ImmutableList.of(MediaTypes.HAL_JSON)); converter.setObjectMapper(mapper); - RestTemplate template = new RestTemplate(Collections.>singletonList(converter)); + RestTemplate template = new RestTemplate(Collections.> singletonList(converter)); return template; } diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TaskanaEngineControllerIntTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TaskanaEngineControllerIntTest.java index c67706f58..a072e488d 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TaskanaEngineControllerIntTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TaskanaEngineControllerIntTest.java @@ -30,6 +30,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import pro.taskana.TaskanaRole; import pro.taskana.rest.resource.TaskanaUserInfoResource; +/** + * Test TaskanaEngineController. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) public class TaskanaEngineControllerIntTest { @@ -99,7 +103,7 @@ public class TaskanaEngineControllerIntTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TestSchemaNameCustomizable.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TestSchemaNameCustomizable.java index 33f1ef612..551157eec 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TestSchemaNameCustomizable.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/TestSchemaNameCustomizable.java @@ -26,6 +26,10 @@ import pro.taskana.configuration.SpringTaskanaEngineConfiguration; import pro.taskana.exceptions.SystemException; import pro.taskana.sampledata.SampleDataGenerator; +/** + * Test that the schema name can be customized. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class TestSchemaNameCustomizable { @@ -78,7 +82,7 @@ public class TestSchemaNameCustomizable { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/WorkbasketAccessItemControllerIntTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/WorkbasketAccessItemControllerIntTest.java index 1e006af74..706e75db3 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/WorkbasketAccessItemControllerIntTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/WorkbasketAccessItemControllerIntTest.java @@ -36,6 +36,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import pro.taskana.rest.resource.WorkbasketAccessItemResource; +/** + * Test WorkbasketAccessItemController. + * + */ @FixMethodOrder(MethodSorters.NAME_ASCENDING) @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @@ -142,7 +146,7 @@ public class WorkbasketAccessItemControllerIntTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */ diff --git a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/WorkbasketControllerIntTest.java b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/WorkbasketControllerIntTest.java index c954676b0..7caf9eed7 100644 --- a/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/WorkbasketControllerIntTest.java +++ b/rest/taskana-rest-spring-example/src/test/java/pro/taskana/rest/WorkbasketControllerIntTest.java @@ -38,6 +38,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import pro.taskana.rest.resource.DistributionTargetResource; import pro.taskana.rest.resource.WorkbasketSummaryResource; +/** + * Test WorkbasketController. + * + */ @RunWith(SpringRunner.class) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) @@ -151,7 +155,7 @@ public class WorkbasketControllerIntTest { } /** - * Return a REST template which is capable of dealing with responses in HAL format + * Return a REST template which is capable of dealing with responses in HAL format. * * @return RestTemplate */