TSK-775 part2 correct missing adaptions to checkstyle template

This commit is contained in:
BerndBreier 2019-01-31 16:27:34 +01:00 committed by Jose Ignacio Recuerda Cambil
parent 8789dd5bf5
commit aa3db31ad5
35 changed files with 799 additions and 609 deletions

View File

@ -100,7 +100,7 @@ public class TaskHistoryEventController extends AbstractPagingController {
@Transactional(readOnly = true, rollbackFor = Exception.class) @Transactional(readOnly = true, rollbackFor = Exception.class)
public ResponseEntity<PagedResources<TaskHistoryEventResource>> getTaskHistoryEvent( public ResponseEntity<PagedResources<TaskHistoryEventResource>> getTaskHistoryEvent(
@RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException { @RequestParam MultiValueMap<String, String> params) throws InvalidArgumentException {
if(LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to getTaskHistoryEvent(params= {})", LoggerUtils.mapToString(params)); LOGGER.debug("Entry to getTaskHistoryEvent(params= {})", LoggerUtils.mapToString(params));
} }
@ -129,7 +129,7 @@ public class TaskHistoryEventController extends AbstractPagingController {
TaskHistoryEventListAssembler assembler = new TaskHistoryEventListAssembler(); TaskHistoryEventListAssembler assembler = new TaskHistoryEventListAssembler();
PagedResources<TaskHistoryEventResource> pagedResources = assembler.toResources(historyEvents, pageMetadata); PagedResources<TaskHistoryEventResource> pagedResources = assembler.toResources(historyEvents, pageMetadata);
if(LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from getTaskHistoryEvent(), returning {}", new ResponseEntity<>(pagedResources, HttpStatus.OK)); 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<String, String> params) private HistoryQuery applySortingParams(HistoryQuery query, MultiValueMap<String, String> params)
throws IllegalArgumentException, InvalidArgumentException { throws IllegalArgumentException, InvalidArgumentException {
if(LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applySortingParams(params= {})", LoggerUtils.mapToString(params)); 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_BY);
params.remove(SORT_DIRECTION); params.remove(SORT_DIRECTION);
if(LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applySortingParams(), returning {}", query); LOGGER.debug("Exit from applySortingParams(), returning {}", query);
} }
@ -226,7 +226,7 @@ public class TaskHistoryEventController extends AbstractPagingController {
private HistoryQuery applyFilterParams(HistoryQuery query, private HistoryQuery applyFilterParams(HistoryQuery query,
MultiValueMap<String, String> params) { MultiValueMap<String, String> params) {
if(LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Entry to applyFilterParams(query= {}, params= {})", query, params); 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); query.custom4Like(LIKE + params.get(CUSTOM_4_LIKE).get(0) + LIKE);
params.remove(CUSTOM_4_LIKE); params.remove(CUSTOM_4_LIKE);
} }
if(LOGGER.isDebugEnabled()) { if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Exit from applyFilterParams(), returning {}", query); LOGGER.debug("Exit from applyFilterParams(), returning {}", query);
} }

View File

@ -247,20 +247,20 @@ public class TaskHistoryEventResource extends ResourceSupport {
@Override @Override
public String toString() { public String toString() {
return "TaskHistoryEventResource [" + return "TaskHistoryEventResource ["
"taskHistoryEventId= " + this.taskHistoryEventId + + "taskHistoryEventId= " + this.taskHistoryEventId
"businessProcessId= " + this.businessProcessId + + "businessProcessId= " + this.businessProcessId
"parentBusinessProcessId= " + this.parentBusinessProcessId + + "parentBusinessProcessId= " + this.parentBusinessProcessId
"taskId= " + this.taskId + + "taskId= " + this.taskId
"eventType= " + this.eventType + + "eventType= " + this.eventType
"created= " + this.created + + "created= " + this.created
"userId= " + this.userId + + "userId= " + this.userId
"domain= " + this.domain + + "domain= " + this.domain
"workbasketKey= " + this.workbasketKey + + "workbasketKey= " + this.workbasketKey
"oldValue= " + this.oldValue + + "oldValue= " + this.oldValue
"newValue= " + this.newValue + + "newValue= " + this.newValue
"oldData= " + this.oldData + + "oldData= " + this.oldData
"newData= " + this.newData + + "newData= " + this.newData
"]"; + "]";
} }
} }

View File

@ -67,9 +67,9 @@ public class SampleDataGenerator {
} }
private StringReader selectSchemaScript(String dbProductName, String schemaName) { private StringReader selectSchemaScript(String dbProductName, String schemaName) {
return new StringReader("PostgreSQL".equals(dbProductName) ? return new StringReader("PostgreSQL".equals(dbProductName)
"SET search_path TO " + schemaName + ";" : ? "SET search_path TO " + schemaName + ";"
"SET SCHEMA " + schemaName + ";"); : "SET SCHEMA " + schemaName + ";");
} }
} }

View File

@ -31,6 +31,9 @@ import org.springframework.web.context.WebApplicationContext;
import pro.taskana.historyPlugin.config.TaskHistoryRestConfiguration; import pro.taskana.historyPlugin.config.TaskHistoryRestConfiguration;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/**
* Controller for Rest documentation.
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = {RestConfiguration.class, TaskHistoryRestConfiguration.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = {RestConfiguration.class, TaskHistoryRestConfiguration.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TaskHistoryEventControllerRestDocumentation { public class TaskHistoryEventControllerRestDocumentation {
@ -64,36 +67,36 @@ public class TaskHistoryEventControllerRestDocumentation {
.withRequestDefaults(prettyPrint())) .withRequestDefaults(prettyPrint()))
.build(); .build();
taskHistoryEventFieldDescriptionsMap.put("_embedded.taskHistoryId","Unique ID"); taskHistoryEventFieldDescriptionsMap.put("_embedded.taskHistoryId", "Unique ID");
taskHistoryEventFieldDescriptionsMap.put("_embedded.businessProcessId","The id of the business process"); taskHistoryEventFieldDescriptionsMap.put("_embedded.businessProcessId", "The id of the business process");
taskHistoryEventFieldDescriptionsMap.put("_embedded.parentBusinessProcessId","The id of the parent 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.taskId", "The id of the task");
taskHistoryEventFieldDescriptionsMap.put("_embedded.eventType","The type of the event"); taskHistoryEventFieldDescriptionsMap.put("_embedded.eventType", "The type of the event");
taskHistoryEventFieldDescriptionsMap.put("_embedded.created","The time was created"); taskHistoryEventFieldDescriptionsMap.put("_embedded.created", "The time was created");
taskHistoryEventFieldDescriptionsMap.put("_embedded.userId","The id of the user"); taskHistoryEventFieldDescriptionsMap.put("_embedded.userId", "The id of the user");
taskHistoryEventFieldDescriptionsMap.put("_embedded.domain","Domain"); taskHistoryEventFieldDescriptionsMap.put("_embedded.domain", "Domain");
taskHistoryEventFieldDescriptionsMap.put("_embedded.workbasketKey","The key of workbasket"); taskHistoryEventFieldDescriptionsMap.put("_embedded.workbasketKey", "The key of workbasket");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porCompany",""); taskHistoryEventFieldDescriptionsMap.put("_embedded.porCompany", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porSystem",""); taskHistoryEventFieldDescriptionsMap.put("_embedded.porSystem", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porInstance",""); taskHistoryEventFieldDescriptionsMap.put("_embedded.porInstance", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porValue",""); taskHistoryEventFieldDescriptionsMap.put("_embedded.porValue", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.porType",""); taskHistoryEventFieldDescriptionsMap.put("_embedded.porType", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationKey","The key of classification task"); taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationKey", "The key of classification task");
taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationCategory","The category of classification"); taskHistoryEventFieldDescriptionsMap.put("_embedded.taskClassificationCategory", "The category of classification");
taskHistoryEventFieldDescriptionsMap.put("_embedded.attachmentClassificationKey",""); taskHistoryEventFieldDescriptionsMap.put("_embedded.attachmentClassificationKey", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.comment",""); taskHistoryEventFieldDescriptionsMap.put("_embedded.comment", "");
taskHistoryEventFieldDescriptionsMap.put("_embedded.oldValue","The old value"); taskHistoryEventFieldDescriptionsMap.put("_embedded.oldValue", "The old value");
taskHistoryEventFieldDescriptionsMap.put("_embedded.newValue","The new value"); taskHistoryEventFieldDescriptionsMap.put("_embedded.newValue", "The new value");
taskHistoryEventFieldDescriptionsMap.put("_embedded.custom1","A custom property with name \"1\""); taskHistoryEventFieldDescriptionsMap.put("_embedded.custom1", "A custom property with name \"1\"");
taskHistoryEventFieldDescriptionsMap.put("_embedded.custom2","A custom property with name \"2\""); taskHistoryEventFieldDescriptionsMap.put("_embedded.custom2", "A custom property with name \"2\"");
taskHistoryEventFieldDescriptionsMap.put("_embedded.custom3","A custom property with name \"3\""); taskHistoryEventFieldDescriptionsMap.put("_embedded.custom3", "A custom property with name \"3\"");
taskHistoryEventFieldDescriptionsMap.put("_embedded.custom4","A custom property with name \"4\""); taskHistoryEventFieldDescriptionsMap.put("_embedded.custom4", "A custom property with name \"4\"");
taskHistoryEventFieldDescriptionsMap.put("_embedded.oldData","The old data"); taskHistoryEventFieldDescriptionsMap.put("_embedded.oldData", "The old data");
taskHistoryEventFieldDescriptionsMap.put("_embedded.newData","The new data"); taskHistoryEventFieldDescriptionsMap.put("_embedded.newData", "The new data");
taskHistoryEventFieldDescriptionsMap.put("_links.self.href","The links of this task history event"); 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.allTaskHistoryEvent.href", "Link to all task history event");
taskHistoryEventFieldDescriptionsMap.put("_links.first.href","Link to the first result"); taskHistoryEventFieldDescriptionsMap.put("_links.first.href", "Link to the first result");
taskHistoryEventFieldDescriptionsMap.put("_links.last.href","Link to the last result"); taskHistoryEventFieldDescriptionsMap.put("_links.last.href", "Link to the last result");
allTaskHistoryEventFieldDescriptors = new FieldDescriptor[] { allTaskHistoryEventFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.taskHistoryEventResourceList").description("An array of Task history event"), subsectionWithPath("_embedded.taskHistoryEventResourceList").description("An array of Task history event"),

View File

@ -37,6 +37,10 @@ import pro.taskana.historyPlugin.config.TaskHistoryRestConfiguration;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.TaskHistoryEventResource; import pro.taskana.rest.resource.TaskHistoryEventResource;
/**
* Controller for integration test.
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = {RestConfiguration.class, TaskHistoryRestConfiguration.class}, @SpringBootTest(classes = {RestConfiguration.class, TaskHistoryRestConfiguration.class},
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) 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 * @return RestTemplate
*/ */

View File

@ -15,9 +15,15 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View File

@ -362,6 +362,8 @@ public class LdapCacheTestImpl implements LdapCache {
case 3: case 3:
group3.add(group); group3.add(group);
break; break;
default:
break;
} }
groupNumber = (groupNumber + 1) % 4; groupNumber = (groupNumber + 1) % 4;
} }
@ -382,6 +384,8 @@ public class LdapCacheTestImpl implements LdapCache {
case 3: case 3:
users.put(item, group3); users.put(item, group3);
break; break;
default:
break;
} }
} }
countUser = (countUser + 1) % 4; countUser = (countUser + 1) % 4;

View File

@ -14,7 +14,10 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.SerializationFeature;
/**
* The Web MVC Configuration.
*
*/
@Configuration @Configuration
@EnableWebMvc @EnableWebMvc
public class WebMvcConfig implements WebMvcConfigurer { public class WebMvcConfig implements WebMvcConfigurer {

View File

@ -7,6 +7,9 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* The login controller.
*/
@Controller @Controller
public class LoginController implements WebMvcConfigurer { public class LoginController implements WebMvcConfigurer {
private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class); private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);

View File

@ -3,6 +3,9 @@ package pro.taskana.rest.controllers;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
/**
* The view controller.
*/
@Controller @Controller
public class ViewController { public class ViewController {

View File

@ -1,5 +1,8 @@
package pro.taskana.rest.models; package pro.taskana.rest.models;
/**
* model for a user.
*
*/
public class User { public class User {
private String username; private String username;

View File

@ -10,9 +10,7 @@ import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback; import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.spi.LoginModule; import javax.security.auth.spi.LoginModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.stereotype.Component;
import pro.taskana.ldap.LdapCacheTestImpl; import pro.taskana.ldap.LdapCacheTestImpl;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdResource;

View File

@ -29,6 +29,9 @@ import static org.springframework.security.test.web.servlet.setup.SecurityMockMv
import java.util.HashMap; import java.util.HashMap;
/**
* Generate Rest Docu for AbstractPagingController.
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class AbstractPagingControllerRestDocumentation { public class AbstractPagingControllerRestDocumentation {

View File

@ -38,7 +38,10 @@ import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/**
* Generate REST Dokumentation for ClassificationController.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class ClassificationControllerRestDocumentation { public class ClassificationControllerRestDocumentation {

View File

@ -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.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; 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.responseFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
import static org.springframework.restdocs.request.RequestDocumentation.partWithName; import static org.springframework.restdocs.request.RequestDocumentation.partWithName;
@ -33,6 +32,10 @@ import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/**
* Test ClassificationDefinitionControlller.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class ClassificationDefinitionControllerRestDocumentation { public class ClassificationDefinitionControllerRestDocumentation {

View File

@ -31,6 +31,10 @@ import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/**
* Generate common REST Documentation.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class CommonRestDocumentation { public class CommonRestDocumentation {

View File

@ -30,6 +30,10 @@ import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/**
* Generate REST docu for the monitor controller.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class MonitorControllerRestDocumentation { public class MonitorControllerRestDocumentation {
@ -71,7 +75,8 @@ public class MonitorControllerRestDocumentation {
subsectionWithPath("rows").description("Object holding the rows of the report.\n" subsectionWithPath("rows").description("Object holding the rows of the report.\n"
+ "For the exact structure please check the example response above"), + "For the exact structure please check the example response above"),
fieldWithPath("sumRow").description("Object holding the sums in the columns over all rows"), 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" 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"), + "For the exact structure please check the example response above"),
fieldWithPath("sumRow.total").description("Total number of tasks"), fieldWithPath("sumRow.total").description("Total number of tasks"),
fieldWithPath("_links.self.href").ignored() fieldWithPath("_links.self.href").ignored()
@ -91,7 +96,8 @@ public class MonitorControllerRestDocumentation {
@Test @Test
public void tasksWorkbasketReport() throws Exception { public void tasksWorkbasketReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/v1/monitor/tasks-workbasket-report?daysInPast=4&states=READY,CLAIMED,COMPLETED") .get("http://127.0.0.1:" + port
+ "/v1/monitor/tasks-workbasket-report?daysInPast=4&states=READY,CLAIMED,COMPLETED")
.accept("application/hal+json") .accept("application/hal+json")
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) .header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())

View File

@ -1,5 +1,23 @@
package pro.taskana.doc.api; 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.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
@ -18,25 +36,16 @@ import org.springframework.test.web.servlet.MvcResult;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
import static org.junit.Assert.assertEquals; /**
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; * Generate REST Documentation for the TaskController.
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;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class TaskControllerRestDocumentation { public class TaskControllerRestDocumentation {
@LocalServerPort @LocalServerPort
int port; int port;
@ -70,32 +79,41 @@ public class TaskControllerRestDocumentation {
.build(); .build();
taskFieldDescriptionsMap.put("taskId", "Unique ID"); 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("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("claimed", "The timestamp of the last claim-operation on the task");
taskFieldDescriptionsMap.put("completed", "The timestamp of the completion of 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("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("planned",
taskFieldDescriptionsMap.put("due", "Timestamp when the task is due. The actual completion of the task should be between PLANNED and DUE."); "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("name", "The name of the task");
taskFieldDescriptionsMap.put("creator", ""); taskFieldDescriptionsMap.put("creator", "");
taskFieldDescriptionsMap.put("description", "The description of the task"); taskFieldDescriptionsMap.put("description", "The description of the task");
taskFieldDescriptionsMap.put("note", "note"); taskFieldDescriptionsMap.put("note", "note");
taskFieldDescriptionsMap.put("priority", "The priority of the task"); taskFieldDescriptionsMap.put("priority", "The priority of the task");
taskFieldDescriptionsMap.put("state", "he state of the task. See (...)"); taskFieldDescriptionsMap.put("state", "he state of the task. See (...)");
taskFieldDescriptionsMap.put("classificationSummaryResource", "The <<classification-subset, Classification>> of the task"); taskFieldDescriptionsMap.put("classificationSummaryResource",
"The <<classification-subset, Classification>> of the task");
taskFieldDescriptionsMap.put("workbasketSummaryResource", "The <<workbasket-subset, Workbasket>> of the task"); taskFieldDescriptionsMap.put("workbasketSummaryResource", "The <<workbasket-subset, Workbasket>> of the task");
taskFieldDescriptionsMap.put("businessProcessId", ""); taskFieldDescriptionsMap.put("businessProcessId", "");
taskFieldDescriptionsMap.put("parentBusinessProcessId", ""); taskFieldDescriptionsMap.put("parentBusinessProcessId", "");
taskFieldDescriptionsMap.put("owner", "The owner of the tasks. The owner is set upon claiming of the task."); taskFieldDescriptionsMap.put("owner", "The owner of the tasks. The owner is set upon claiming of the task.");
taskFieldDescriptionsMap.put("primaryObjRef.id", ""); taskFieldDescriptionsMap.put("primaryObjRef.id", "");
taskFieldDescriptionsMap.put("primaryObjRef.company", "The company referenced primary object belongs to."); 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.system",
taskFieldDescriptionsMap.put("primaryObjRef.systemInstance", "The instance of the system, the object resides in."); "The (kind of) system, the object resides in (e.g. SAP, MySystem A, ...) ");
taskFieldDescriptionsMap.put("primaryObjRef.type", "The type of the reference (contract, claim, policy, customer, ...)"); 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("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("customAttributes",
taskFieldDescriptionsMap.put("callbackInfo", "A container for all callback information of the task in JSON representation"); "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("attachments", "");
taskFieldDescriptionsMap.put("custom1", "A custom property with name \"1\""); taskFieldDescriptionsMap.put("custom1", "A custom property with name \"1\"");
taskFieldDescriptionsMap.put("custom2", "A custom property with name \"2\""); taskFieldDescriptionsMap.put("custom2", "A custom property with name \"2\"");
@ -141,15 +159,20 @@ public class TaskControllerRestDocumentation {
fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"), fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"),
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
subsectionWithPath("classificationSummaryResource").description(taskFieldDescriptionsMap.get("classificationSummaryResource")), subsectionWithPath("classificationSummaryResource")
subsectionWithPath("workbasketSummaryResource").description(taskFieldDescriptionsMap.get("workbasketSummaryResource")), .description(taskFieldDescriptionsMap.get("classificationSummaryResource")),
subsectionWithPath("workbasketSummaryResource")
.description(taskFieldDescriptionsMap.get("workbasketSummaryResource")),
fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")), fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")),
fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), fieldWithPath("parentBusinessProcessId")
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"), fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"),
fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String"), fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
.type("String"),
fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), fieldWithPath("primaryObjRef.systemInstance")
.description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")),
fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")), fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")),
@ -192,15 +215,20 @@ public class TaskControllerRestDocumentation {
fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"), fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note"),
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")), fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")),
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")), fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")),
subsectionWithPath("classificationSummaryResource").description(taskFieldDescriptionsMap.get("classificationSummaryResource")), subsectionWithPath("classificationSummaryResource")
subsectionWithPath("workbasketSummaryResource").description(taskFieldDescriptionsMap.get("workbasketSummaryResource")), .description(taskFieldDescriptionsMap.get("classificationSummaryResource")),
subsectionWithPath("workbasketSummaryResource")
.description(taskFieldDescriptionsMap.get("workbasketSummaryResource")),
fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")), fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")),
fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), fieldWithPath("parentBusinessProcessId")
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")), fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")),
fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String"), fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
.type("String"),
fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), fieldWithPath("primaryObjRef.systemInstance")
.description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")),
fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")), fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")),
@ -229,12 +257,17 @@ public class TaskControllerRestDocumentation {
createTaskFieldDescriptors = new FieldDescriptor[] { createTaskFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("classificationSummaryResource").description("The new classificationSummaryResource for the task"), subsectionWithPath("classificationSummaryResource")
subsectionWithPath("workbasketSummaryResource").description("The new workbasketSummaryResource for the task"), .description("The new classificationSummaryResource for the task"),
fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")).type("String").optional(), 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.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), fieldWithPath("primaryObjRef.systemInstance")
.description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")),
fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")).type("String").optional(), fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")).type("String").optional(),
@ -245,17 +278,35 @@ public class TaskControllerRestDocumentation {
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String").optional(), fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String").optional(),
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")).type("String").optional(), fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")).type("String").optional(),
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")).type("String").optional(), fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")).type("String").optional(),
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")).type("String").optional(), fieldWithPath("description").description(taskFieldDescriptionsMap.get("description"))
fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note").type("String").optional(), .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("priority").description(taskFieldDescriptionsMap.get("priority")).type("String").optional(),
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")).type("String").optional(), fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")).type("String").optional(),
fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")).type("String").optional(), fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId"))
fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")).type("String").optional(), .type("String")
.optional(),
fieldWithPath("parentBusinessProcessId")
.description(taskFieldDescriptionsMap.get("parentBusinessProcessId"))
.type("String")
.optional(),
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String").optional(), fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String").optional(),
fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String").optional(), fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")).type("Object").optional(), .type("String")
fieldWithPath("callbackInfo").description(taskFieldDescriptionsMap.get("callbackInfo")).type("Object").optional(), .optional(),
fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")).type("Array").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("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String").optional(),
fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String").optional(), fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String").optional(),
fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String").optional(), fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String").optional(),
@ -273,7 +324,9 @@ public class TaskControllerRestDocumentation {
fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String").optional(), fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String").optional(),
fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String").optional(), fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String").optional(),
fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")).type("Boolean").optional(), fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")).type("Boolean").optional(),
fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")).type("Boolean").optional() fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred"))
.type("Boolean")
.optional()
}; };
} }
@ -311,7 +364,7 @@ public class TaskControllerRestDocumentation {
} }
@Test @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"); URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000");
HttpURLConnection con = (HttpURLConnection) url.openConnection(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET"); con.setRequestMethod("GET");
@ -346,9 +399,9 @@ public class TaskControllerRestDocumentation {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/v1/tasks") .post("http://127.0.0.1:" + port + "/v1/tasks")
.contentType("application/hal+json") .contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isCreated()) .andExpect(MockMvcResultMatchers.status().isCreated())
.andDo(MockMvcRestDocumentation.document("CreateTaskDocTest", .andDo(MockMvcRestDocumentation.document("CreateTaskDocTest",
@ -361,7 +414,7 @@ public class TaskControllerRestDocumentation {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
} }
@ -372,9 +425,9 @@ public class TaskControllerRestDocumentation {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/v1/tasks") .post("http://127.0.0.1:" + port + "/v1/tasks")
.contentType("application/hal+json") .contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isCreated()) .andExpect(MockMvcResultMatchers.status().isCreated())
.andDo(MockMvcRestDocumentation.document("temp")) .andDo(MockMvcRestDocumentation.document("temp"))
@ -385,16 +438,16 @@ public class TaskControllerRestDocumentation {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/claim") .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/claim")
.accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json") .content("{}"))
.content("\"userName\":\"teamlead_1\""))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("ClaimTaskDocTest", .andDo(MockMvcRestDocumentation.document("ClaimTaskDocTest",
responseFields(taskFieldDescriptors))); responseFields(taskFieldDescriptors)));
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
} }
@ -404,9 +457,9 @@ public class TaskControllerRestDocumentation {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/v1/tasks") .post("http://127.0.0.1:" + port + "/v1/tasks")
.contentType("application/hal+json") .contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isCreated()) .andExpect(MockMvcResultMatchers.status().isCreated())
.andDo(MockMvcRestDocumentation.document("temp")) .andDo(MockMvcRestDocumentation.document("temp"))
@ -426,7 +479,7 @@ public class TaskControllerRestDocumentation {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest")); .andDo(MockMvcRestDocumentation.document("DeleteTaskDocTest"));
} }
@ -436,9 +489,9 @@ public class TaskControllerRestDocumentation {
MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders MvcResult result = this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/v1/tasks") .post("http://127.0.0.1:" + port + "/v1/tasks")
.contentType("application/hal+json") .contentType("application/hal+json")
.content("{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + .content("{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}") + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isCreated()) .andExpect(MockMvcResultMatchers.status().isCreated())
.andDo(MockMvcRestDocumentation.document("TransferTaskDocTest", .andDo(MockMvcRestDocumentation.document("TransferTaskDocTest",
@ -449,7 +502,8 @@ public class TaskControllerRestDocumentation {
String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40); String newId = content.substring(content.indexOf("TKI:"), content.indexOf("TKI:") + 40);
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/transfer/WBI:100000000000000000000000000000000001") .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId
+ "/transfer/WBI:100000000000000000000000000000000001")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("TransferTaskDocTest", .andDo(MockMvcRestDocumentation.document("TransferTaskDocTest",
@ -457,7 +511,7 @@ public class TaskControllerRestDocumentation {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId) .delete("http://127.0.0.1:" + port + "/v1/tasks/" + newId)
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) //admin .header("Authorization", "Basic YWRtaW46YWRtaW4=")) // admin
.andExpect(MockMvcResultMatchers.status().isNoContent()); .andExpect(MockMvcResultMatchers.status().isNoContent());
} }
} }

View File

@ -29,9 +29,14 @@ import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/**
* Generate REST Docu for the TaskanaEngineController.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class TaskanaEngineControllerRestDocumentation { public class TaskanaEngineControllerRestDocumentation {
@LocalServerPort @LocalServerPort
int port; int port;

View File

@ -1,5 +1,16 @@
package pro.taskana.doc.api; 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.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; 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.result.MockMvcResultMatchers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
import java.util.HashMap; /**
* Generate REST Docu for the WorkbasketAccessItemController.
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;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class WorkbasketAccessItemControllerRestDocumentation { public class WorkbasketAccessItemControllerRestDocumentation {
@LocalServerPort @LocalServerPort
int port; int port;
@ -62,14 +67,20 @@ public class WorkbasketAccessItemControllerRestDocumentation {
accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessItemId", "Unique ID"); accessItemFieldDescriptionsMap.put("_embedded.accessItems.accessItemId", "Unique ID");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketId", "The workbasket 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.accessName", "The name");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.workbasketKey", "The workbasket key"); 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.permRead",
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permOpen", "The permission to view the content (the tasks) of a workbasket"); "The permission to read the information about the 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.permOpen",
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permTransfer", "The permission to transfer tasks (out of the current workbasket)"); "The permission to view the content (the tasks) of a workbasket");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permDistribute", "The permission to distribute tasks from the 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.permCustom1", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom2", ""); accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom2", "");
accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom3", ""); accessItemFieldDescriptionsMap.put("_embedded.accessItems.permCustom3", "");
@ -86,28 +97,50 @@ public class WorkbasketAccessItemControllerRestDocumentation {
accessItemFieldDescriptionsMap.put("page", "Number of page"); accessItemFieldDescriptionsMap.put("page", "Number of page");
accessItemFieldDescriptors = new FieldDescriptor[] { accessItemFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("_embedded.accessItems[].accessItemId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")), fieldWithPath("_embedded.accessItems[].accessItemId")
fieldWithPath("_embedded.accessItems[].workbasketId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessItemId")),
fieldWithPath("_embedded.accessItems[].accessId").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")), fieldWithPath("_embedded.accessItems[].workbasketId")
fieldWithPath("_embedded.accessItems[].accessName").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketId")),
fieldWithPath("_embedded.accessItems[].workbasketKey").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketKey")), fieldWithPath("_embedded.accessItems[].accessId")
fieldWithPath("_embedded.accessItems[].permRead").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessId")),
fieldWithPath("_embedded.accessItems[].permOpen").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")), fieldWithPath("_embedded.accessItems[].accessName")
fieldWithPath("_embedded.accessItems[].permAppend").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.accessName")),
fieldWithPath("_embedded.accessItems[].permTransfer").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")), fieldWithPath("_embedded.accessItems[].workbasketKey")
fieldWithPath("_embedded.accessItems[].permDistribute").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.workbasketKey")),
fieldWithPath("_embedded.accessItems[].permCustom1").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom1")), fieldWithPath("_embedded.accessItems[].permRead")
fieldWithPath("_embedded.accessItems[].permCustom2").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom2")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permRead")),
fieldWithPath("_embedded.accessItems[].permCustom3").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom3")), fieldWithPath("_embedded.accessItems[].permOpen")
fieldWithPath("_embedded.accessItems[].permCustom4").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom4")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permOpen")),
fieldWithPath("_embedded.accessItems[].permCustom5").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom5")), fieldWithPath("_embedded.accessItems[].permAppend")
fieldWithPath("_embedded.accessItems[].permCustom6").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom6")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permAppend")),
fieldWithPath("_embedded.accessItems[].permCustom7").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom7")), fieldWithPath("_embedded.accessItems[].permTransfer")
fieldWithPath("_embedded.accessItems[].permCustom8").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom8")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permTransfer")),
fieldWithPath("_embedded.accessItems[].permCustom9").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom9")), fieldWithPath("_embedded.accessItems[].permDistribute")
fieldWithPath("_embedded.accessItems[].permCustom10").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom10")), .description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permDistribute")),
fieldWithPath("_embedded.accessItems[].permCustom11").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom11")), fieldWithPath("_embedded.accessItems[].permCustom1")
fieldWithPath("_embedded.accessItems[].permCustom12").description(accessItemFieldDescriptionsMap.get("_embedded.accessItems.permCustom12")), .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("_links.self.href").description(accessItemFieldDescriptionsMap.get("_links.self.href")),
fieldWithPath("page").description(accessItemFieldDescriptionsMap.get("page")) fieldWithPath("page").description(accessItemFieldDescriptionsMap.get("page"))
}; };
@ -115,7 +148,10 @@ public class WorkbasketAccessItemControllerRestDocumentation {
@Test @Test
public void getWorkbasketAccessItemsDocTest() throws Exception { 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") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
@ -125,7 +161,9 @@ public class WorkbasketAccessItemControllerRestDocumentation {
@Test @Test
public void removeWorkbasketAccessItemsDocTest() throws Exception { 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")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isNoContent()) .andExpect(MockMvcResultMatchers.status().isNoContent())
.andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest")); .andDo(MockMvcRestDocumentation.document("RemoveWorkbasketAccessItemsDocTest"));

View File

@ -38,6 +38,9 @@ import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/**
* Generate REST Documentatioon for the WorkbasketController.
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class WorkbasketControllerRestDocumentation { public class WorkbasketControllerRestDocumentation {
@ -269,28 +272,39 @@ public class WorkbasketControllerRestDocumentation {
fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")), fieldWithPath("domain").description(workbasketFieldDescriptionsMap.get("domain")),
fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")), fieldWithPath("type").description(workbasketFieldDescriptionsMap.get("type")),
fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description")) fieldWithPath("description").description(workbasketFieldDescriptionsMap.get("description"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")).type("String").optional(), fieldWithPath("owner").description(workbasketFieldDescriptionsMap.get("owner")).type("String").optional(),
fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1")) fieldWithPath("orgLevel1").description(workbasketFieldDescriptionsMap.get("orgLevel1"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2")) fieldWithPath("orgLevel2").description(workbasketFieldDescriptionsMap.get("orgLevel2"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3")) fieldWithPath("orgLevel3").description(workbasketFieldDescriptionsMap.get("orgLevel3"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4")) fieldWithPath("orgLevel4").description(workbasketFieldDescriptionsMap.get("orgLevel4"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("created").description(workbasketFieldDescriptionsMap.get("created")) fieldWithPath("created").description(workbasketFieldDescriptionsMap.get("created"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("modified").description(workbasketFieldDescriptionsMap.get("modified")) fieldWithPath("modified").description(workbasketFieldDescriptionsMap.get("modified"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1")) fieldWithPath("custom1").description(workbasketFieldDescriptionsMap.get("custom1"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2")) fieldWithPath("custom2").description(workbasketFieldDescriptionsMap.get("custom2"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3")) fieldWithPath("custom3").description(workbasketFieldDescriptionsMap.get("custom3"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4")) fieldWithPath("custom4").description(workbasketFieldDescriptionsMap.get("custom4"))
.type("String").optional(), .type("String")
.optional(),
fieldWithPath("_links.distributionTargets.href").description( fieldWithPath("_links.distributionTargets.href").description(
workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")).type("String").optional(), workbasketFieldDescriptionsMap.get("_links.distributionTargets.href")).type("String").optional(),
fieldWithPath("_links.removeDistributionTargets.href").description( fieldWithPath("_links.removeDistributionTargets.href").description(

View File

@ -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.preprocessRequest;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse; import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessResponse;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint; 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.responseFields;
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
import static org.springframework.restdocs.request.RequestDocumentation.partWithName; import static org.springframework.restdocs.request.RequestDocumentation.partWithName;
@ -33,6 +32,10 @@ import org.springframework.web.context.WebApplicationContext;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/**
* Generate Rest Documentation for Workbasket Definitions.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class WorkbasketDefinitionControllerRestDocumentation { public class WorkbasketDefinitionControllerRestDocumentation {
@ -96,7 +99,6 @@ public class WorkbasketDefinitionControllerRestDocumentation {
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(document("ImportWorkbasketDefinitions", requestParts( .andDo(document("ImportWorkbasketDefinitions", requestParts(
partWithName("file").description("The file to upload")) partWithName("file").description("The file to upload"))));
));
} }
} }

View File

@ -17,6 +17,10 @@ import pro.taskana.history.HistoryEventProducer;
import pro.taskana.impl.TaskanaEngineImpl; import pro.taskana.impl.TaskanaEngineImpl;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
/**
* test loading of history plugin.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@ActiveProfiles(profiles = "history.plugin") @ActiveProfiles(profiles = "history.plugin")
@SpringBootTest(classes = RestConfiguration.class) @SpringBootTest(classes = RestConfiguration.class)

View File

@ -46,10 +46,13 @@ import pro.taskana.Task;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationResource;
import pro.taskana.rest.resource.TaskResource;
import pro.taskana.rest.resource.ClassificationResourceAssembler; import pro.taskana.rest.resource.ClassificationResourceAssembler;
import pro.taskana.rest.resource.TaskResource;
import pro.taskana.rest.resource.TaskResourceAssembler; import pro.taskana.rest.resource.TaskResourceAssembler;
/**
* Test async updates.
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT,
properties = {"devMode=true"}) properties = {"devMode=true"})
@ -121,7 +124,8 @@ public class AsyncUpdateJobIntTest {
long delay = 16000; 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); Thread.sleep(delay);
LOGGER.info("Sleeping ended. Continuing .... "); 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 * @return RestTemplate
*/ */
@ -201,7 +205,7 @@ public class AsyncUpdateJobIntTest {
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json")); converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/hal+json"));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
return template; return template;
} }

View File

@ -17,6 +17,10 @@ import pro.taskana.impl.util.LoggerUtils;
import pro.taskana.rest.RestConfiguration; import pro.taskana.rest.RestConfiguration;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdResource;
/**
* Test Ldap attachment.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) @SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
@ContextConfiguration(classes = {RestConfiguration.class}) @ContextConfiguration(classes = {RestConfiguration.class})

View File

@ -14,7 +14,6 @@ import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.context.annotation.Import;
import org.springframework.core.ParameterizedTypeReference; import org.springframework.core.ParameterizedTypeReference;
import org.springframework.hateoas.hal.Jackson2HalModule; import org.springframework.hateoas.hal.Jackson2HalModule;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
@ -35,6 +34,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.ldap.LdapCacheTestImpl; import pro.taskana.ldap.LdapCacheTestImpl;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdResource;
/**
* Test AccessIdValidation.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"devMode=true"}) "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 * @return RestTemplate
*/ */

View File

@ -15,8 +15,6 @@ import java.util.Collections;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
@ -45,24 +43,24 @@ import pro.taskana.Task;
import pro.taskana.exceptions.InvalidArgumentException; import pro.taskana.exceptions.InvalidArgumentException;
import pro.taskana.rest.resource.ClassificationSummaryResource; import pro.taskana.rest.resource.ClassificationSummaryResource;
import pro.taskana.rest.resource.TaskResource; import pro.taskana.rest.resource.TaskResource;
import pro.taskana.rest.resource.ClassificationResourceAssembler;
import pro.taskana.rest.resource.TaskResourceAssembler; import pro.taskana.rest.resource.TaskResourceAssembler;
/**
* Test ClassificationController.
* @author bbr
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT,
properties = {"devMode=true"}) properties = {"devMode=true"})
public class ClassificationControllerIntTest { public class ClassificationControllerIntTest {
@Autowired
private ClassificationResourceAssembler classificationResourceAssembler;
@Autowired @Autowired
private TaskResourceAssembler taskResourceAssembler; private TaskResourceAssembler taskResourceAssembler;
@Autowired @Autowired
Environment env; Environment env;
private static final Logger LOGGER = LoggerFactory.getLogger(ClassificationControllerIntTest.class);
String server = "http://127.0.0.1:"; String server = "http://127.0.0.1:";
RestTemplate template; RestTemplate template;
HttpEntity<String> request; HttpEntity<String> 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 * @return RestTemplate
*/ */

View File

@ -46,6 +46,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.rest.resource.ClassificationResource; import pro.taskana.rest.resource.ClassificationResource;
import pro.taskana.rest.resource.ClassificationSummaryResource; import pro.taskana.rest.resource.ClassificationSummaryResource;
/**
* Test classification definitions.
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {
"devMode=true"}) "devMode=true"})
@ -76,8 +79,7 @@ public class ClassificationDefinitionControllerIntTest {
ResponseEntity<ClassificationResource[]> response = template.exchange( ResponseEntity<ClassificationResource[]> response = template.exchange(
server + port + "/v1/classification-definitions?domain=DOMAIN_B", server + port + "/v1/classification-definitions?domain=DOMAIN_B",
HttpMethod.GET, request, new ParameterizedTypeReference<ClassificationResource[]>() { HttpMethod.GET, request, new ParameterizedTypeReference<ClassificationResource[]>() {
} });
);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.OK, response.getStatusCode());
assertTrue(response.getBody().length >= 5); assertTrue(response.getBody().length >= 5);
assertTrue(response.getBody().length <= 7); assertTrue(response.getBody().length <= 7);
@ -88,8 +90,7 @@ public class ClassificationDefinitionControllerIntTest {
ResponseEntity<ClassificationResource[]> response = template.exchange( ResponseEntity<ClassificationResource[]> response = template.exchange(
server + port + "/v1/classification-definitions?domain=ADdfe", server + port + "/v1/classification-definitions?domain=ADdfe",
HttpMethod.GET, request, new ParameterizedTypeReference<ClassificationResource[]>() { HttpMethod.GET, request, new ParameterizedTypeReference<ClassificationResource[]>() {
} });
);
assertEquals(0, response.getBody().length); assertEquals(0, response.getBody().length);
} }
@ -150,7 +151,7 @@ public class ClassificationDefinitionControllerIntTest {
try { try {
importRequest(clList); importRequest(clList);
} catch(HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
} }
} }
@ -164,7 +165,7 @@ public class ClassificationDefinitionControllerIntTest {
try { try {
importRequest(clList); importRequest(clList);
} catch(HttpClientErrorException e) { } catch (HttpClientErrorException e) {
assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode()); assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
} }
} }
@ -174,7 +175,8 @@ public class ClassificationDefinitionControllerIntTest {
ClassificationResource classification1 = this.createClassification("id1", "ImportKey1", "DOMAIN_A", null, null); ClassificationResource classification1 = this.createClassification("id1", "ImportKey1", "DOMAIN_A", null, null);
String c1 = objMapper.writeValueAsString(classification1); 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.setCategory("MANUAL");
classification2.setType("TASK"); classification2.setType("TASK");
classification2.setIsValidInDomain(true); classification2.setIsValidInDomain(true);
@ -231,7 +233,8 @@ public class ClassificationDefinitionControllerIntTest {
response = importRequest(clList); response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); 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()); assertEquals("second new Name", testClassification.getName());
} }
@ -263,15 +266,18 @@ public class ClassificationDefinitionControllerIntTest {
@Test @Test
public void testImportParentAndChildClassification() throws IOException { 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); 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); String c21 = objMapper.writeValueAsString(classification2);
classification2 = this.createClassification("childId2", "ImportKey8", "DOMAIN_A", "parentId", null); classification2 = this.createClassification("childId2", "ImportKey8", "DOMAIN_A", "parentId", null);
String c22 = objMapper.writeValueAsString(classification2); 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); String c31 = objMapper.writeValueAsString(classification3);
classification3 = this.createClassification("grandchild2", "ImportKey10", "DOMAIN_A", null, "ImportKey7"); classification3 = this.createClassification("grandchild2", "ImportKey10", "DOMAIN_A", null, "ImportKey7");
String c32 = objMapper.writeValueAsString(classification3); String c32 = objMapper.writeValueAsString(classification3);
@ -286,7 +292,6 @@ public class ClassificationDefinitionControllerIntTest {
ResponseEntity<String> response = importRequest(clList); ResponseEntity<String> response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.OK, response.getStatusCode());
ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A"); ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("ImportKey6", "DOMAIN_A");
ClassificationSummaryResource childCl = getClassificationWithKeyAndDomain("ImportKey7", "DOMAIN_A"); ClassificationSummaryResource childCl = getClassificationWithKeyAndDomain("ImportKey7", "DOMAIN_A");
ClassificationSummaryResource grandchildCl = getClassificationWithKeyAndDomain("ImportKey9", "DOMAIN_A"); ClassificationSummaryResource grandchildCl = getClassificationWithKeyAndDomain("ImportKey9", "DOMAIN_A");
@ -303,9 +308,11 @@ public class ClassificationDefinitionControllerIntTest {
ClassificationResource classification1 = createClassification("parent", "ImportKey11", "DOMAIN_A", null, null); ClassificationResource classification1 = createClassification("parent", "ImportKey11", "DOMAIN_A", null, null);
classification1.setCustom1("parent is correct"); classification1.setCustom1("parent is correct");
String parent = objMapper.writeValueAsString(classification1); 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); 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); String child = objMapper.writeValueAsString(classification3);
List<String> clList = new ArrayList<>(); List<String> clList = new ArrayList<>();
@ -327,7 +334,8 @@ public class ClassificationDefinitionControllerIntTest {
assertNotEquals(wrongParentCl.getClassificationId(), childCl.getParentId()); 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 classificationResource = new ClassificationResource();
classificationResource.setClassificationId(id); classificationResource.setClassificationId(id);
classificationResource.setKey(key); classificationResource.setKey(key);
@ -353,7 +361,7 @@ public class ClassificationDefinitionControllerIntTest {
return response.getBody().getContent().toArray(new ClassificationSummaryResource[1])[0]; return response.getBody().getContent().toArray(new ClassificationSummaryResource[1])[0];
} }
private ResponseEntity<String> importRequest (List<String> clList) throws IOException { private ResponseEntity<String> importRequest(List<String> clList) throws IOException {
LOGGER.debug("Start Import"); LOGGER.debug("Start Import");
File tmpFile = File.createTempFile("test", ".tmp"); File tmpFile = File.createTempFile("test", ".tmp");
FileWriter writer = new FileWriter(tmpFile); FileWriter writer = new FileWriter(tmpFile);
@ -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 * @return RestTemplate
*/ */
@ -385,7 +393,7 @@ public class ClassificationDefinitionControllerIntTest {
converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/haljson,*/*")); converter.setSupportedMediaTypes(MediaType.parseMediaTypes("application/haljson,*/*"));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
return template; return template;
} }
} }

View File

@ -13,11 +13,7 @@ import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Captor; import org.mockito.Captor;
import org.mockito.Mock; import org.mockito.Mock;
import ch.qos.logback.classic.Logger;
import org.slf4j.LoggerFactory; 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;
import org.springframework.boot.web.server.LocalServerPort; import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.core.ParameterizedTypeReference; 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.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.LoggingEvent; import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender; import ch.qos.logback.core.Appender;
import pro.taskana.ldap.LdapCacheTestImpl; import pro.taskana.ldap.LdapCacheTestImpl;
import pro.taskana.rest.resource.AccessIdResource; import pro.taskana.rest.resource.AccessIdResource;
import pro.taskana.rest.resource.ClassificationSummaryResource; 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) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { @SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
"devMode=true"}) "devMode=true"})
public class GenenalExceptionHandlingTest { public class GenenalExceptionHandlingTest {
@Autowired
private ClassificationResourceAssembler classificationResourceAssembler;
@Autowired
private TaskResourceAssembler taskResourceAssembler;
String server = "http://127.0.0.1:"; String server = "http://127.0.0.1:";
RestTemplate template; RestTemplate template;
HttpEntity<String> request; HttpEntity<String> 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 * @return RestTemplate
*/ */

View File

@ -50,6 +50,9 @@ import pro.taskana.exceptions.SystemException;
import pro.taskana.rest.resource.TaskSummaryResource; import pro.taskana.rest.resource.TaskSummaryResource;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
/**
* Test Task Controller.
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT,
properties = {"devMode=true"}) properties = {"devMode=true"})
@ -374,9 +377,9 @@ public class TaskControllerIntTest {
@Test @Test
public void testCreateAndDeleteTask() throws IOException { public void testCreateAndDeleteTask() throws IOException {
String taskToCreateJson = "{\"classificationSummaryResource\":{\"key\":\"L11010\"}," + String taskToCreateJson = "{\"classificationSummaryResource\":{\"key\":\"L11010\"},"
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks"); URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks");
HttpURLConnection con = (HttpURLConnection) url.openConnection(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
@ -417,9 +420,9 @@ public class TaskControllerIntTest {
@Test @Test
public void testCreateTaskWithInvalidParameter() throws IOException { public void testCreateTaskWithInvalidParameter() throws IOException {
String taskToCreateJson = "{\"classificationKey\":\"L11010\"," + String taskToCreateJson = "{\"classificationKey\":\"L11010\","
"\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"}," + + "\"workbasketSummaryResource\":{\"workbasketId\":\"WBI:100000000000000000000000000000000004\"},"
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}"; + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks"); URL url = new URL("http://127.0.0.1:" + port + "/v1/tasks");
HttpURLConnection con = (HttpURLConnection) url.openConnection(); HttpURLConnection con = (HttpURLConnection) url.openConnection();
@ -434,11 +437,9 @@ public class TaskControllerIntTest {
assertEquals(400, con.getResponseCode()); assertEquals(400, con.getResponseCode());
con.disconnect(); con.disconnect();
taskToCreateJson = taskToCreateJson = "{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"},"
"{\"classificationSummaryResource\":{\"classificationId\":\"CLI:100000000000000000000000000000000004\"}," + "\"workbasketSummaryResource\":{\"workbasketId\":\"\"},"
+ + "\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
"\"workbasketSummaryResource\":{\"workbasketId\":\"\"}," +
"\"primaryObjRef\":{\"company\":\"MyCompany1\",\"system\":\"MySystem1\",\"systemInstance\":\"MyInstance1\",\"type\":\"MyType1\",\"value\":\"00000001\"}}";
url = new URL("http://127.0.0.1:" + port + "/v1/tasks"); url = new URL("http://127.0.0.1:" + port + "/v1/tasks");
con = (HttpURLConnection) url.openConnection(); 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 * @return RestTemplate
*/ */
@ -470,7 +471,7 @@ public class TaskControllerIntTest {
// converter.setSupportedMediaTypes(ImmutableList.of(MediaTypes.HAL_JSON)); // converter.setSupportedMediaTypes(ImmutableList.of(MediaTypes.HAL_JSON));
converter.setObjectMapper(mapper); converter.setObjectMapper(mapper);
RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter)); RestTemplate template = new RestTemplate(Collections.<HttpMessageConverter<?>> singletonList(converter));
return template; return template;
} }

View File

@ -30,6 +30,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.TaskanaRole; import pro.taskana.TaskanaRole;
import pro.taskana.rest.resource.TaskanaUserInfoResource; import pro.taskana.rest.resource.TaskanaUserInfoResource;
/**
* Test TaskanaEngineController.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"}) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {"devMode=true"})
public class TaskanaEngineControllerIntTest { 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 * @return RestTemplate
*/ */

View File

@ -26,6 +26,10 @@ import pro.taskana.configuration.SpringTaskanaEngineConfiguration;
import pro.taskana.exceptions.SystemException; import pro.taskana.exceptions.SystemException;
import pro.taskana.sampledata.SampleDataGenerator; import pro.taskana.sampledata.SampleDataGenerator;
/**
* Test that the schema name can be customized.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class TestSchemaNameCustomizable { 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 * @return RestTemplate
*/ */

View File

@ -36,6 +36,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.rest.resource.WorkbasketAccessItemResource; import pro.taskana.rest.resource.WorkbasketAccessItemResource;
/**
* Test WorkbasketAccessItemController.
*
*/
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @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 * @return RestTemplate
*/ */

View File

@ -38,6 +38,10 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import pro.taskana.rest.resource.DistributionTargetResource; import pro.taskana.rest.resource.DistributionTargetResource;
import pro.taskana.rest.resource.WorkbasketSummaryResource; import pro.taskana.rest.resource.WorkbasketSummaryResource;
/**
* Test WorkbasketController.
*
*/
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT, @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT,
properties = {"devMode=true"}) 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 * @return RestTemplate
*/ */