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

@ -43,7 +43,7 @@ public class ExampleRestApplication {
@Autowired @Autowired
private SampleDataGenerator sampleDataGenerator; private SampleDataGenerator sampleDataGenerator;
@Autowired @Autowired
private LdapClient ldapClient; private LdapClient ldapClient;
@ -85,7 +85,7 @@ public class ExampleRestApplication {
AccessIdController.setLdapCache(ldapCacheTest); AccessIdController.setLdapCache(ldapCacheTest);
} }
if (generateSampleData) { if (generateSampleData) {
sampleDataGenerator.generateSampleData(schemaName); sampleDataGenerator.generateSampleData(schemaName);
} }
} }
} }

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,31 +29,34 @@ 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 {
@LocalServerPort @LocalServerPort
int port; int port;
@Rule @Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@Autowired @Autowired
private WebApplicationContext context; private WebApplicationContext context;
private MockMvc mockMvc; private MockMvc mockMvc;
private HashMap<String, String> pagingFieldDescriptionsMap = new HashMap<String, String>(); private HashMap<String, String> pagingFieldDescriptionsMap = new HashMap<String, String>();
private FieldDescriptor[] pagingFieldDescriptors; private FieldDescriptor[] pagingFieldDescriptors;
@Before @Before
public void setUp() { public void setUp() {
document("{methodName}", document("{methodName}",
preprocessRequest(prettyPrint()), preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint())); preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity()) .apply(springSecurity())
.apply(documentationConfiguration(this.restDocumentation) .apply(documentationConfiguration(this.restDocumentation)
@ -61,7 +64,7 @@ public class AbstractPagingControllerRestDocumentation {
.withResponseDefaults(prettyPrint()) .withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint())) .withRequestDefaults(prettyPrint()))
.build(); .build();
pagingFieldDescriptionsMap.put("page", "Contains metainfo if there are multiple pages, else it is null"); pagingFieldDescriptionsMap.put("page", "Contains metainfo if there are multiple pages, else it is null");
pagingFieldDescriptionsMap.put("page.size", "Number of items per page"); pagingFieldDescriptionsMap.put("page.size", "Number of items per page");
pagingFieldDescriptionsMap.put("page.totalElements", "Total number of items"); pagingFieldDescriptionsMap.put("page.totalElements", "Total number of items");
@ -71,10 +74,10 @@ public class AbstractPagingControllerRestDocumentation {
pagingFieldDescriptionsMap.put("_links.first.href", "Link to first page"); pagingFieldDescriptionsMap.put("_links.first.href", "Link to first page");
pagingFieldDescriptionsMap.put("_links.last.href", "Link to last page"); pagingFieldDescriptionsMap.put("_links.last.href", "Link to last page");
pagingFieldDescriptionsMap.put("_links.prev.href", "Link to previous page"); pagingFieldDescriptionsMap.put("_links.prev.href", "Link to previous page");
pagingFieldDescriptionsMap.put("_links.next.href", "Link to next page"); pagingFieldDescriptionsMap.put("_links.next.href", "Link to next page");
pagingFieldDescriptors = new FieldDescriptor[] { pagingFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.classificationSummaryResourceList").ignored(), subsectionWithPath("_embedded.classificationSummaryResourceList").ignored(),
fieldWithPath("_links").ignored(), fieldWithPath("_links").ignored(),
fieldWithPath("_links.self").ignored(), fieldWithPath("_links.self").ignored(),
@ -91,7 +94,7 @@ public class AbstractPagingControllerRestDocumentation {
fieldWithPath("_links.next.href").description(pagingFieldDescriptionsMap.get("_links.next.href")) fieldWithPath("_links.next.href").description(pagingFieldDescriptionsMap.get("_links.next.href"))
}; };
} }
@Test @Test
public void commonSummaryResourceFieldsDocTest() throws Exception { public void commonSummaryResourceFieldsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders

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,72 +30,78 @@ 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 {
@LocalServerPort @LocalServerPort
int port; int port;
@Rule @Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@Autowired @Autowired
private WebApplicationContext context; private WebApplicationContext context;
private MockMvc mockMvc; private MockMvc mockMvc;
private FieldDescriptor[] taskReportFieldDescriptors; private FieldDescriptor[] taskReportFieldDescriptors;
@Before @Before
public void setUp() { public void setUp() {
document("{methodName}", document("{methodName}",
preprocessRequest(prettyPrint()), preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint())); preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity()) .apply(springSecurity())
.apply(documentationConfiguration(this.restDocumentation) .apply(documentationConfiguration(this.restDocumentation)
.operationPreprocessors() .operationPreprocessors()
.withResponseDefaults(prettyPrint()) .withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint())) .withRequestDefaults(prettyPrint()))
.build(); .build();
taskReportFieldDescriptors = new FieldDescriptor[] { taskReportFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("meta").description("Object holding metainfo on the report"), fieldWithPath("meta").description("Object holding metainfo on the report"),
fieldWithPath("meta.name").description("Name of the report"), fieldWithPath("meta.name").description("Name of the report"),
fieldWithPath("meta.date").description("Date of the report creation"), fieldWithPath("meta.date").description("Date of the report creation"),
fieldWithPath("meta.header").description("Column-headers of the report"), fieldWithPath("meta.header").description("Column-headers of the report"),
fieldWithPath("meta.rowDesc").description("Descriptions for the rows the report"), fieldWithPath("meta.rowDesc").description("Descriptions for the rows the report"),
fieldWithPath("meta.totalDesc").description("Description for the report itself"), fieldWithPath("meta.totalDesc").description("Description for the report itself"),
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")
+ "For the exact structure please check the example response above"), .description("Contains the accumulated numbers over all columns defined in meta.header.\n"
fieldWithPath("sumRow.total").description("Total number of tasks"), + "For the exact structure please check the example response above"),
fieldWithPath("_links.self.href").ignored() fieldWithPath("sumRow.total").description("Total number of tasks"),
fieldWithPath("_links.self.href").ignored()
}; };
} }
@Test @Test
public void getTaskStatusReport() throws Exception { public void getTaskStatusReport() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/v1/monitor/tasks-status-report") .get("http://127.0.0.1:" + port + "/v1/monitor/tasks-status-report")
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) .header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetTaskStatusReportDocTest", .andDo(MockMvcRestDocumentation.document("GetTaskStatusReportDocTest",
responseFields(taskReportFieldDescriptors))); responseFields(taskReportFieldDescriptors)));
} }
@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
.accept("application/hal+json") + "/v1/monitor/tasks-workbasket-report?daysInPast=4&states=READY,CLAIMED,COMPLETED")
.header("Authorization", "Basic YWRtaW46YWRtaW4=")) .accept("application/hal+json")
.andExpect(MockMvcResultMatchers.status().isOk()) .header("Authorization", "Basic YWRtaW46YWRtaW4="))
.andDo(MockMvcRestDocumentation.document("GetTaskWorkbasketReportDocTest", .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetTaskWorkbasketReportDocTest",
responseFields(taskReportFieldDescriptors))); responseFields(taskReportFieldDescriptors)));
} }

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,84 +36,84 @@ 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;
@Rule @Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@Autowired @Autowired
private WebApplicationContext context; private WebApplicationContext context;
private MockMvc mockMvc; private MockMvc mockMvc;
private HashMap<String, String> taskFieldDescriptionsMap = new HashMap<String, String>(); private HashMap<String, String> taskFieldDescriptionsMap = new HashMap<String, String>();
private FieldDescriptor[] allTasksFieldDescriptors; private FieldDescriptor[] allTasksFieldDescriptors;
private FieldDescriptor[] taskFieldDescriptors; private FieldDescriptor[] taskFieldDescriptors;
private FieldDescriptor[] taskSubsetFieldDescriptors; private FieldDescriptor[] taskSubsetFieldDescriptors;
private FieldDescriptor[] createTaskFieldDescriptors; private FieldDescriptor[] createTaskFieldDescriptors;
@Before @Before
public void setUp() { public void setUp() {
document("{methodName}", document("{methodName}",
preprocessRequest(prettyPrint()), preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint())); preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity()) .apply(springSecurity())
.apply(documentationConfiguration(this.restDocumentation) .apply(documentationConfiguration(this.restDocumentation)
.operationPreprocessors() .operationPreprocessors()
.withResponseDefaults(prettyPrint()) .withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint())) .withRequestDefaults(prettyPrint()))
.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\"");
@ -115,203 +133,238 @@ public class TaskControllerRestDocumentation {
taskFieldDescriptionsMap.put("custom16", "A custom property with name \"16\""); taskFieldDescriptionsMap.put("custom16", "A custom property with name \"16\"");
taskFieldDescriptionsMap.put("read", "Indicator if the task has been read"); taskFieldDescriptionsMap.put("read", "Indicator if the task has been read");
taskFieldDescriptionsMap.put("transferred", "Indicator if the task has been transferred"); taskFieldDescriptionsMap.put("transferred", "Indicator if the task has been transferred");
allTasksFieldDescriptors = new FieldDescriptor[] { allTasksFieldDescriptors = new FieldDescriptor[] {
subsectionWithPath("_embedded.tasks").description("An Array of <<task-subset, Task-Subsets>>"), subsectionWithPath("_embedded.tasks").description("An Array of <<task-subset, Task-Subsets>>"),
fieldWithPath("_links").ignored(), fieldWithPath("_links").ignored(),
fieldWithPath("_links.self").ignored(), fieldWithPath("_links.self").ignored(),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("page").ignored() fieldWithPath("page").ignored()
}; };
taskFieldDescriptors = new FieldDescriptor[] { taskFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")), fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")),
fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")), fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")),
fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")), fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")),
fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String"), fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String"),
fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"), fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"),
fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"), fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"),
fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"), fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"),
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")), fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")),
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")),
fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")), subsectionWithPath("workbasketSummaryResource")
fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), .description(taskFieldDescriptionsMap.get("workbasketSummaryResource")),
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"), fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")),
fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String"), fieldWithPath("parentBusinessProcessId")
fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), .description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String"),
fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), .type("String"),
fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")), fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")), fieldWithPath("primaryObjRef.systemInstance")
fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")), .description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
fieldWithPath("callbackInfo").description(taskFieldDescriptionsMap.get("callbackInfo")), fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")), fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")),
fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String"), fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")),
fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String"), fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")),
fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String"), fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")),
fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String"), fieldWithPath("callbackInfo").description(taskFieldDescriptionsMap.get("callbackInfo")),
fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String"), fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")),
fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String"), fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String"),
fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String"), fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String"),
fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String"), fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String"),
fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String"), fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String"),
fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String"), fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String"),
fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String"), fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String"),
fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String"), fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String"),
fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String"), fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String"),
fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String"), fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String"),
fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String"), fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String"),
fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String"), fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String"),
fieldWithPath("_links.self.href").ignored() fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String"),
fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String"),
fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String"),
fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String"),
fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String"),
fieldWithPath("_links.self.href").ignored()
}; };
taskSubsetFieldDescriptors = new FieldDescriptor[] { taskSubsetFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")), fieldWithPath("taskId").description(taskFieldDescriptionsMap.get("taskId")),
fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")), fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId")),
fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")), fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")),
fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")), fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")),
fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"), fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String"),
fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"), fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String"),
fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"), fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String"),
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"), fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String"),
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")), fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")),
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")), fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")),
fieldWithPath("description").ignored(), fieldWithPath("description").ignored(),
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")),
fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")), subsectionWithPath("workbasketSummaryResource")
fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")), .description(taskFieldDescriptionsMap.get("workbasketSummaryResource")),
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")), fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")),
fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String"), fieldWithPath("parentBusinessProcessId")
fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), .description(taskFieldDescriptionsMap.get("parentBusinessProcessId")),
fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")),
fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), .type("String"),
fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")), fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")), fieldWithPath("primaryObjRef.systemInstance")
fieldWithPath("customAttributes").ignored(), .description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
fieldWithPath("callbackInfo").ignored(), fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")), fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")),
fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")), fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")),
fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")), fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")),
fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")), fieldWithPath("customAttributes").ignored(),
fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")), fieldWithPath("callbackInfo").ignored(),
fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")), fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")),
fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")), fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")),
fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")), fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")),
fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")), fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")),
fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")), fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")),
fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")), fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")),
fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")), fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")),
fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")), fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")),
fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")), fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")),
fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")), fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")),
fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")), fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")),
fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")), fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")),
fieldWithPath("_links.self.href").ignored() fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")),
fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")),
fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")),
fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")),
fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")),
fieldWithPath("_links.self.href").ignored()
}; };
createTaskFieldDescriptors = new FieldDescriptor[] { 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")
fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")), .description("The new workbasketSummaryResource for the task"),
fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")), fieldWithPath("externalId").description(taskFieldDescriptionsMap.get("externalId"))
fieldWithPath("primaryObjRef.systemInstance").description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")), .type("String")
fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")), .optional(),
fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")), fieldWithPath("primaryObjRef.company").description(taskFieldDescriptionsMap.get("primaryObjRef.company")),
fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")).type("String").optional(), fieldWithPath("primaryObjRef.system").description(taskFieldDescriptionsMap.get("primaryObjRef.system")),
fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String").optional(), fieldWithPath("primaryObjRef.systemInstance")
fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String").optional(), .description(taskFieldDescriptionsMap.get("primaryObjRef.systemInstance")),
fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String").optional(), fieldWithPath("primaryObjRef.type").description(taskFieldDescriptionsMap.get("primaryObjRef.type")),
fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String").optional(), fieldWithPath("primaryObjRef.value").description(taskFieldDescriptionsMap.get("primaryObjRef.value")),
fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String").optional(), fieldWithPath("created").description(taskFieldDescriptionsMap.get("created")).type("String").optional(),
fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")).type("String").optional(), fieldWithPath("claimed").description(taskFieldDescriptionsMap.get("claimed")).type("String").optional(),
fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")).type("String").optional(), fieldWithPath("completed").description(taskFieldDescriptionsMap.get("completed")).type("String").optional(),
fieldWithPath("description").description(taskFieldDescriptionsMap.get("description")).type("String").optional(), fieldWithPath("modified").description(taskFieldDescriptionsMap.get("modified")).type("String").optional(),
fieldWithPath("note").description(taskFieldDescriptionsMap.get("note")).description("Some custom Note").type("String").optional(), fieldWithPath("planned").description(taskFieldDescriptionsMap.get("planned")).type("String").optional(),
fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")).type("String").optional(), fieldWithPath("due").description(taskFieldDescriptionsMap.get("due")).type("String").optional(),
fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")).type("String").optional(), fieldWithPath("name").description(taskFieldDescriptionsMap.get("name")).type("String").optional(),
fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId")).type("String").optional(), fieldWithPath("creator").description(taskFieldDescriptionsMap.get("creator")).type("String").optional(),
fieldWithPath("parentBusinessProcessId").description(taskFieldDescriptionsMap.get("parentBusinessProcessId")).type("String").optional(), fieldWithPath("description").description(taskFieldDescriptionsMap.get("description"))
fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String").optional(), .type("String")
fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id")).type("String").optional(), .optional(),
fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes")).type("Object").optional(), fieldWithPath("note").description(taskFieldDescriptionsMap.get("note"))
fieldWithPath("callbackInfo").description(taskFieldDescriptionsMap.get("callbackInfo")).type("Object").optional(), .description("Some custom Note")
fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments")).type("Array").optional(), .type("String")
fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String").optional(), .optional(),
fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String").optional(), fieldWithPath("priority").description(taskFieldDescriptionsMap.get("priority")).type("String").optional(),
fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String").optional(), fieldWithPath("state").description(taskFieldDescriptionsMap.get("state")).type("String").optional(),
fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String").optional(), fieldWithPath("businessProcessId").description(taskFieldDescriptionsMap.get("businessProcessId"))
fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String").optional(), .type("String")
fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String").optional(), .optional(),
fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String").optional(), fieldWithPath("parentBusinessProcessId")
fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String").optional(), .description(taskFieldDescriptionsMap.get("parentBusinessProcessId"))
fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String").optional(), .type("String")
fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String").optional(), .optional(),
fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String").optional(), fieldWithPath("owner").description(taskFieldDescriptionsMap.get("owner")).type("String").optional(),
fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String").optional(), fieldWithPath("primaryObjRef.id").description(taskFieldDescriptionsMap.get("primaryObjRef.id"))
fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String").optional(), .type("String")
fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String").optional(), .optional(),
fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String").optional(), fieldWithPath("customAttributes").description(taskFieldDescriptionsMap.get("customAttributes"))
fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String").optional(), .type("Object")
fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")).type("Boolean").optional(), .optional(),
fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred")).type("Boolean").optional() fieldWithPath("callbackInfo").description(taskFieldDescriptionsMap.get("callbackInfo"))
.type("Object")
.optional(),
fieldWithPath("attachments").description(taskFieldDescriptionsMap.get("attachments"))
.type("Array")
.optional(),
fieldWithPath("custom1").description(taskFieldDescriptionsMap.get("custom1")).type("String").optional(),
fieldWithPath("custom2").description(taskFieldDescriptionsMap.get("custom2")).type("String").optional(),
fieldWithPath("custom3").description(taskFieldDescriptionsMap.get("custom3")).type("String").optional(),
fieldWithPath("custom4").description(taskFieldDescriptionsMap.get("custom4")).type("String").optional(),
fieldWithPath("custom5").description(taskFieldDescriptionsMap.get("custom5")).type("String").optional(),
fieldWithPath("custom6").description(taskFieldDescriptionsMap.get("custom6")).type("String").optional(),
fieldWithPath("custom7").description(taskFieldDescriptionsMap.get("custom7")).type("String").optional(),
fieldWithPath("custom8").description(taskFieldDescriptionsMap.get("custom8")).type("String").optional(),
fieldWithPath("custom9").description(taskFieldDescriptionsMap.get("custom9")).type("String").optional(),
fieldWithPath("custom10").description(taskFieldDescriptionsMap.get("custom10")).type("String").optional(),
fieldWithPath("custom11").description(taskFieldDescriptionsMap.get("custom11")).type("String").optional(),
fieldWithPath("custom12").description(taskFieldDescriptionsMap.get("custom12")).type("String").optional(),
fieldWithPath("custom13").description(taskFieldDescriptionsMap.get("custom13")).type("String").optional(),
fieldWithPath("custom14").description(taskFieldDescriptionsMap.get("custom14")).type("String").optional(),
fieldWithPath("custom15").description(taskFieldDescriptionsMap.get("custom15")).type("String").optional(),
fieldWithPath("custom16").description(taskFieldDescriptionsMap.get("custom16")).type("String").optional(),
fieldWithPath("read").description(taskFieldDescriptionsMap.get("read")).type("Boolean").optional(),
fieldWithPath("transferred").description(taskFieldDescriptionsMap.get("transferred"))
.type("Boolean")
.optional()
}; };
} }
@Test @Test
public void getAllTasksDocTest() throws Exception { public void getAllTasksDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/v1/tasks?por.type=VNR&por.value=22334455") .get("http://127.0.0.1:" + port + "/v1/tasks?por.type=VNR&por.value=22334455")
.accept("application/hal+json") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllTasksDocTest", .andDo(MockMvcRestDocumentation.document("GetAllTasksDocTest",
responseFields(allTasksFieldDescriptors))); responseFields(allTasksFieldDescriptors)));
} }
@Test @Test
public void getSpecificTaskDocTest() throws Exception { public void getSpecificTaskDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000") .get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000")
.accept("application/hal+json") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetSpecificTaskDocTest", .andDo(MockMvcRestDocumentation.document("GetSpecificTaskDocTest",
responseFields(taskFieldDescriptors))); responseFields(taskFieldDescriptors)));
} }
@Test @Test
public void taskSubSetDocTest() throws Exception { public void taskSubSetDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000") .get("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000")
.accept("application/hal+json") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("TaskSubset", .andDo(MockMvcRestDocumentation.document("TaskSubset",
responseFields(taskSubsetFieldDescriptors))); responseFields(taskSubsetFieldDescriptors)));
} }
@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");
@ -330,134 +383,135 @@ public class TaskControllerRestDocumentation {
String originalTask = content.toString(); String originalTask = content.toString();
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.put("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000") .put("http://127.0.0.1:" + port + "/v1/tasks/TKI:100000000000000000000000000000000000")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.contentType("application/json") .contentType("application/json")
.content(originalTask)) .content(originalTask))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("UpdateTaskDocTest", .andDo(MockMvcRestDocumentation.document("UpdateTaskDocTest",
requestFields(taskFieldDescriptors), requestFields(taskFieldDescriptors),
responseFields(taskFieldDescriptors))); responseFields(taskFieldDescriptors)));
} }
@Test @Test
public void createAndDeleteTaskDocTest() throws Exception { public void createAndDeleteTaskDocTest() throws Exception {
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",
requestFields(createTaskFieldDescriptors), requestFields(createTaskFieldDescriptors),
responseFields(taskFieldDescriptors))) responseFields(taskFieldDescriptors)))
.andReturn(); .andReturn();
String content = result.getResponse().getContentAsString(); String content = result.getResponse().getContentAsString();
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
.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"));
} }
@Test @Test
public void claimTaskDocTest() throws Exception { public void claimTaskDocTest() throws Exception {
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"))
.andReturn(); .andReturn();
String content = result.getResponse().getContentAsString(); String content = result.getResponse().getContentAsString();
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 + "/claim") .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/claim")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") .accept("application/hal+json")
.contentType("application/json") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content("\"userName\":\"teamlead_1\"")) .content("{}"))
.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"));
} }
@Test @Test
public void completeTaskDocTest() throws Exception { public void completeTaskDocTest() throws Exception {
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"))
.andReturn(); .andReturn();
String content = result.getResponse().getContentAsString(); String content = result.getResponse().getContentAsString();
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 + "/complete") .post("http://127.0.0.1:" + port + "/v1/tasks/" + newId + "/complete")
.accept("application/hal+json") .accept("application/hal+json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x") .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")
.content("{}")) .content("{}"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("CompleteTaskDocTest", .andDo(MockMvcRestDocumentation.document("CompleteTaskDocTest",
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"));
} }
@Test @Test
public void transferTaskDocTest() throws Exception { public void transferTaskDocTest() throws Exception {
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",
responseFields(taskFieldDescriptors))) responseFields(taskFieldDescriptors)))
.andReturn(); .andReturn();
String content = result.getResponse().getContentAsString(); String content = result.getResponse().getContentAsString();
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
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) + "/transfer/WBI:100000000000000000000000000000000001")
.andExpect(MockMvcResultMatchers.status().isOk()) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andDo(MockMvcRestDocumentation.document("TransferTaskDocTest", .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("TransferTaskDocTest",
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());
} }
} }

View File

@ -29,99 +29,104 @@ 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;
@Rule @Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@Autowired @Autowired
private WebApplicationContext context; private WebApplicationContext context;
private MockMvc mockMvc; private MockMvc mockMvc;
private FieldDescriptor[] allDomainsFieldDescriptors; private FieldDescriptor[] allDomainsFieldDescriptors;
private FieldDescriptor[] allClassificationCategoriesFieldDescriptors; private FieldDescriptor[] allClassificationCategoriesFieldDescriptors;
private FieldDescriptor[] allClassificationTypesFieldDescriptors; private FieldDescriptor[] allClassificationTypesFieldDescriptors;
private FieldDescriptor[] currentUserInfoFieldDescriptors; private FieldDescriptor[] currentUserInfoFieldDescriptors;
@Before @Before
public void setUp() { public void setUp() {
document("{methodName}", document("{methodName}",
preprocessRequest(prettyPrint()), preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint())); preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity()) .apply(springSecurity())
.apply(documentationConfiguration(this.restDocumentation) .apply(documentationConfiguration(this.restDocumentation)
.operationPreprocessors() .operationPreprocessors()
.withResponseDefaults(prettyPrint()) .withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint())) .withRequestDefaults(prettyPrint()))
.build(); .build();
allDomainsFieldDescriptors = new FieldDescriptor[] { allDomainsFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("[]").description("An array with the domain-names as strings") fieldWithPath("[]").description("An array with the domain-names as strings")
}; };
allClassificationCategoriesFieldDescriptors = new FieldDescriptor[] { allClassificationCategoriesFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("[]").description("An array with the classification-categories as strings") fieldWithPath("[]").description("An array with the classification-categories as strings")
}; };
allClassificationTypesFieldDescriptors = new FieldDescriptor[] { allClassificationTypesFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("[]").description("An array with the classification-types as strings") fieldWithPath("[]").description("An array with the classification-types as strings")
}; };
currentUserInfoFieldDescriptors = new FieldDescriptor[] { currentUserInfoFieldDescriptors = new FieldDescriptor[] {
fieldWithPath("userId").description("Id of the current user"), fieldWithPath("userId").description("Id of the current user"),
fieldWithPath("groupIds").description("An array with the groups the current user is part of as strings"), fieldWithPath("groupIds").description("An array with the groups the current user is part of as strings"),
fieldWithPath("roles").description("An array with the roles the current user is granted") fieldWithPath("roles").description("An array with the roles the current user is granted")
}; };
} }
@Test @Test
public void getAllDomainsDocTest() throws Exception { public void getAllDomainsDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/v1/domains") .get("http://127.0.0.1:" + port + "/v1/domains")
.accept("application/json") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllDomainsDocTest", .andDo(MockMvcRestDocumentation.document("GetAllDomainsDocTest",
responseFields(allDomainsFieldDescriptors))); responseFields(allDomainsFieldDescriptors)));
} }
@Test @Test
public void getAllClassificationCategoriesDocTest() throws Exception { public void getAllClassificationCategoriesDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/v1/classification-categories") .get("http://127.0.0.1:" + port + "/v1/classification-categories")
.accept("application/json") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllClassificationCategoriesDocTest", .andDo(MockMvcRestDocumentation.document("GetAllClassificationCategoriesDocTest",
responseFields(allClassificationCategoriesFieldDescriptors))); responseFields(allClassificationCategoriesFieldDescriptors)));
} }
@Test @Test
public void getAllClassificationTypesDocTest() throws Exception { public void getAllClassificationTypesDocTest() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/v1/classification-types") .get("http://127.0.0.1:" + port + "/v1/classification-types")
.accept("application/json") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetAllClassificationTypesDocTest", .andDo(MockMvcRestDocumentation.document("GetAllClassificationTypesDocTest",
responseFields(allClassificationTypesFieldDescriptors))); responseFields(allClassificationTypesFieldDescriptors)));
} }
@Test @Test
public void getCurrentUserInfo() throws Exception { public void getCurrentUserInfo() throws Exception {
this.mockMvc.perform(RestDocumentationRequestBuilders this.mockMvc.perform(RestDocumentationRequestBuilders
.get("http://127.0.0.1:" + port + "/v1/current-user-info") .get("http://127.0.0.1:" + port + "/v1/current-user-info")
.accept("application/json") .accept("application/json")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("GetCurrentUserInfoDocTest", .andDo(MockMvcRestDocumentation.document("GetCurrentUserInfoDocTest",
responseFields(currentUserInfoFieldDescriptors))); responseFields(currentUserInfoFieldDescriptors)));
} }
} }

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;
@ -49,27 +54,33 @@ public class WorkbasketAccessItemControllerRestDocumentation {
@Before @Before
public void setUp() { public void setUp() {
document("{methodName}", document("{methodName}",
preprocessRequest(prettyPrint()), preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint())); preprocessResponse(prettyPrint()));
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context) this.mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
.apply(springSecurity()) .apply(springSecurity())
.apply(documentationConfiguration(this.restDocumentation) .apply(documentationConfiguration(this.restDocumentation)
.operationPreprocessors() .operationPreprocessors()
.withResponseDefaults(prettyPrint()) .withResponseDefaults(prettyPrint())
.withRequestDefaults(prettyPrint())) .withRequestDefaults(prettyPrint()))
.build(); .build();
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,19 +148,24 @@ 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())
.andDo(MockMvcRestDocumentation.document("GetWorkbasketAccessItemsDocTest", .andDo(MockMvcRestDocumentation.document("GetWorkbasketAccessItemsDocTest",
responseFields(accessItemFieldDescriptors))); responseFields(accessItemFieldDescriptors)));
} }
@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 {
@ -53,7 +56,7 @@ public class WorkbasketControllerRestDocumentation {
private MockMvc mockMvc; private MockMvc mockMvc;
// HashMaps to store the field descriptions centrally for multiple uses // HashMaps to store the field descriptions centrally for multiple uses
private HashMap<String, String> workbasketFieldDescriptionsMap = new HashMap<String, String>(); private HashMap<String, String> workbasketFieldDescriptionsMap = new HashMap<String, String>();
private HashMap<String, String> accessItemFieldDescriptionsMap = new HashMap<String, String>(); private HashMap<String, String> accessItemFieldDescriptionsMap = new HashMap<String, String>();
@ -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 @Autowired
private ClassificationResourceAssembler classificationResourceAssembler;
@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"})
@ -65,33 +68,31 @@ public class ClassificationDefinitionControllerIntTest {
@Before @Before
public void before() { public void before() {
LOGGER.debug("before"); LOGGER.debug("before");
template = getRestTemplate(); template = getRestTemplate();
headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"); headers.add("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x");
request = new HttpEntity<String>(headers); request = new HttpEntity<String>(headers);
} }
@Test @Test
public void testExportClassifications() { public void testExportClassifications() {
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);
} }
@Test @Test
public void testExportClassificationsFromWrongDomain() { public void testExportClassificationsFromWrongDomain() {
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);
} }
@Test @Test
public void testImportFilledClassification() throws IOException { public void testImportFilledClassification() throws IOException {
@ -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());
} }
} }
@ -173,8 +174,9 @@ public class ClassificationDefinitionControllerIntTest {
public void testImportMultipleClassifications() throws IOException { public void testImportMultipleClassifications() throws IOException {
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);
@ -223,15 +225,16 @@ public class ClassificationDefinitionControllerIntTest {
ResponseEntity<String> response = importRequest(clList); ResponseEntity<String> response = importRequest(clList);
assertEquals(HttpStatus.OK, response.getStatusCode()); assertEquals(HttpStatus.OK, response.getStatusCode());
existingClassification.setName("second new Name"); existingClassification.setName("second new Name");
clList = new ArrayList<>(); clList = new ArrayList<>();
clList.add(objMapper.writeValueAsString(existingClassification)); clList.add(objMapper.writeValueAsString(existingClassification));
response = importRequest(clList); response = importRequest(clList);
assertEquals(HttpStatus.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());
} }
@ -249,7 +252,7 @@ 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("L11010", "DOMAIN_A"); ClassificationSummaryResource parentCl = getClassificationWithKeyAndDomain("L11010", "DOMAIN_A");
ClassificationSummaryResource testNewCl = getClassificationWithKeyAndDomain("newClass", "DOMAIN_A"); ClassificationSummaryResource testNewCl = getClassificationWithKeyAndDomain("newClass", "DOMAIN_A");
ClassificationSummaryResource testExistingCl = getClassificationWithKeyAndDomain("L110102", "DOMAIN_A"); ClassificationSummaryResource testExistingCl = getClassificationWithKeyAndDomain("L110102", "DOMAIN_A");
@ -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);
@ -285,7 +291,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");
@ -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,18 +361,18 @@ 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);
writer.write(clList.toString()); writer.write(clList.toString());
writer.close(); writer.close();
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>(); MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
headers.setContentType(MediaType.MULTIPART_FORM_DATA); headers.setContentType(MediaType.MULTIPART_FORM_DATA);
body.add("file", new FileSystemResource(tmpFile)); body.add("file", new FileSystemResource(tmpFile));
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers); HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(body, headers);
String serverUrl = server + port + "/v1/classification-definitions"; String serverUrl = server + port + "/v1/classification-definitions";
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
@ -372,7 +380,7 @@ public class ClassificationDefinitionControllerIntTest {
} }
/** /**
* Return a REST template which is capable of dealing with responses in HAL format * Return a REST template which is capable of dealing with responses in HAL format.
* *
* @return RestTemplate * @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();
@ -400,9 +403,9 @@ public class TaskControllerIntTest {
} }
in.close(); in.close();
con.disconnect(); con.disconnect();
String createdTask = responsePayload.toString(); String createdTask = responsePayload.toString();
String taskIdOfCreatedTask = createdTask.substring(createdTask.indexOf("TKI:"), createdTask.indexOf("TKI:") + 40); String taskIdOfCreatedTask = createdTask.substring(createdTask.indexOf("TKI:"), createdTask.indexOf("TKI:") + 40);
assertNotNull(taskIdOfCreatedTask); assertNotNull(taskIdOfCreatedTask);
assertTrue(taskIdOfCreatedTask.startsWith("TKI:")); assertTrue(taskIdOfCreatedTask.startsWith("TKI:"));
@ -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
*/ */