TSK-854: enabled checkstyle javadoc integrity check + fixed issues

This commit is contained in:
Mustapha Zorgati 2019-06-04 09:42:25 +02:00 committed by holgerhagen
parent b5c54e9be9
commit 474a5a3b38
8 changed files with 194 additions and 186 deletions

View File

@ -53,6 +53,27 @@ public class ClassificationServiceImpl implements ClassificationService {
this.taskMapper = taskMapper; this.taskMapper = taskMapper;
} }
private static void validateServiceLevel(String serviceLevel) throws InvalidArgumentException {
try {
Duration.parse(serviceLevel);
} catch (Exception e) {
throw new InvalidArgumentException("Invalid service level " + serviceLevel
+ ". The formats accepted are based on the ISO-8601 duration format PnDTnHnMn.nS with days considered to be exactly 24 hours. "
+ "For example: \"P2D\" represents a period of \"two days.\" ",
e.getCause());
}
// check that the duration is based on format PnD, i.e. it must start with a P, end with a D
String serviceLevelLower = serviceLevel.toLowerCase();
if (!('p' == serviceLevelLower.charAt(0))
|| !('d' == serviceLevelLower.charAt(serviceLevel.length() - 1))) {
throw new InvalidArgumentException(
"Invalid service level " + serviceLevel + ". Taskana only supports service levels that"
+ " contain a number of whole days specified according to the format 'PnD' where n is the number of days");
}
}
@Override @Override
public Classification createClassification(Classification classification) public Classification createClassification(Classification classification)
throws ClassificationAlreadyExistException, NotAuthorizedException, throws ClassificationAlreadyExistException, NotAuthorizedException,
@ -196,7 +217,9 @@ public class ClassificationServiceImpl implements ClassificationService {
/** /**
* Fill missing values and validate classification before saving the classification. * Fill missing values and validate classification before saving the classification.
* *
* @param classification * @param classification the classification which will be verified.
*
* @throws InvalidArgumentException if the given classification has no key.
*/ */
private void initDefaultClassificationValues(ClassificationImpl classification) throws InvalidArgumentException { private void initDefaultClassificationValues(ClassificationImpl classification) throws InvalidArgumentException {
Instant now = Instant.now(); Instant now = Instant.now();
@ -253,27 +276,6 @@ public class ClassificationServiceImpl implements ClassificationService {
} }
} }
private static void validateServiceLevel(String serviceLevel) throws InvalidArgumentException {
try {
Duration.parse(serviceLevel);
} catch (Exception e) {
throw new InvalidArgumentException("Invalid service level " + serviceLevel
+ ". The formats accepted are based on the ISO-8601 duration format PnDTnHnMn.nS with days considered to be exactly 24 hours. "
+ "For example: \"P2D\" represents a period of \"two days.\" ",
e.getCause());
}
// check that the duration is based on format PnD, i.e. it must start with a P, end with a D
String serviceLevelLower = serviceLevel.toLowerCase();
if (!('p' == serviceLevelLower.charAt(0))
|| !('d' == serviceLevelLower.charAt(serviceLevel.length() - 1))) {
throw new InvalidArgumentException(
"Invalid service level " + serviceLevel + ". Taskana only supports service levels that"
+ " contain a number of whole days specified according to the format 'PnD' where n is the number of days");
}
}
@Override @Override
public Classification getClassification(String id) throws ClassificationNotFoundException { public Classification getClassification(String id) throws ClassificationNotFoundException {
if (id == null) { if (id == null) {
@ -343,8 +345,8 @@ public class ClassificationServiceImpl implements ClassificationService {
} }
} catch (Exception ex) { } catch (Exception ex) {
LOGGER.warn( LOGGER.warn(
"Classification-Service throwed Exception while calling mapper and searching for classification. EX={}", "Classification-Service threw Exception while calling mapper and searching for classification. EX={}",
ex); ex, ex);
} }
return isExisting; return isExisting;
} }
@ -433,6 +435,9 @@ public class ClassificationServiceImpl implements ClassificationService {
* *
* @param classificationImpl the classification * @param classificationImpl the classification
* @return the old classification * @return the old classification
*
* @throws ConcurrencyException if the classification has been modified by some other process.
* @throws ClassificationNotFoundException if the given classification does not exist.
*/ */
private Classification getExistingClassificationAndVerifyTimestampHasNotChanged( private Classification getExistingClassificationAndVerifyTimestampHasNotChanged(
ClassificationImpl classificationImpl) ClassificationImpl classificationImpl)
@ -472,6 +477,8 @@ public class ClassificationServiceImpl implements ClassificationService {
* *
* @param classificationImpl the new classification * @param classificationImpl the new classification
* @param oldClassification the old classification * @param oldClassification the old classification
*
* @throws ClassificationNotFoundException if the given classification does not exist.
*/ */
private void checkExistenceOfParentClassification(Classification oldClassification, private void checkExistenceOfParentClassification(Classification oldClassification,
ClassificationImpl classificationImpl) ClassificationImpl classificationImpl)

View File

@ -391,7 +391,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
/** /**
* creates the MyBatis transaction factory. * creates the MyBatis transaction factory.
* *
* @param useManagedTransactions * @param useManagedTransactions true, if managed transations should be used. Otherwise false.
*/ */
private void createTransactionFactory(boolean useManagedTransactions) { private void createTransactionFactory(boolean useManagedTransactions) {
if (useManagedTransactions) { if (useManagedTransactions) {

View File

@ -28,6 +28,7 @@ public class DBCleaner {
/** /**
* Clears the db. * Clears the db.
* *
* @param dataSource the datasource
* @param dropTables * @param dropTables
* if true drop tables, else clean tables * if true drop tables, else clean tables
*/ */
@ -51,7 +52,7 @@ public class DBCleaner {
LOGGER.debug(outWriter.toString()); LOGGER.debug(outWriter.toString());
String errorMsg = errorWriter.toString().trim(); String errorMsg = errorWriter.toString().trim();
if (!errorMsg.isEmpty() && errorMsg.indexOf("SQLCODE=-204, SQLSTATE=42704") == -1) { if (!errorMsg.isEmpty() && !errorMsg.contains("SQLCODE=-204, SQLSTATE=42704")) {
LOGGER.error(errorWriter.toString()); LOGGER.error(errorWriter.toString());
} }
} }

View File

@ -26,21 +26,10 @@ import pro.taskana.configuration.TaskanaEngineConfiguration;
*/ */
public class TaskanaEngineConfigurationTest { public class TaskanaEngineConfigurationTest {
private static DataSource dataSource = null;
private static String schemaName = null;
private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfigurationTest.class); private static final Logger LOGGER = LoggerFactory.getLogger(TaskanaEngineConfigurationTest.class);
private static final int POOL_TIME_TO_WAIT = 50; private static final int POOL_TIME_TO_WAIT = 50;
private static DataSource dataSource = null;
@Test private static String schemaName = null;
public void testCreateTaskanaEngine() throws SQLException {
DataSource ds = getDataSource();
TaskanaEngineConfiguration taskEngineConfiguration = new TaskanaEngineConfiguration(ds, false,
TaskanaEngineConfigurationTest.getSchemaName());
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
Assert.assertNotNull(te);
}
/** /**
* returns the Datasource used for Junit test. If the file {user.home}/taskanaUnitTest.properties is present, the * returns the Datasource used for Junit test. If the file {user.home}/taskanaUnitTest.properties is present, the
@ -69,7 +58,7 @@ public class TaskanaEngineConfigurationTest {
/** /**
* create Default Datasource for in-memory database. * create Default Datasource for in-memory database.
* *
* @return * @return the default datasource.
*/ */
private static DataSource createDefaultDataSource() { private static DataSource createDefaultDataSource() {
// JdbcDataSource ds = new JdbcDataSource(); // JdbcDataSource ds = new JdbcDataSource();
@ -81,10 +70,10 @@ public class TaskanaEngineConfigurationTest {
String jdbcUrl = "jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0"; String jdbcUrl = "jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0";
String dbUserName = "sa"; String dbUserName = "sa";
String dbPassword = "sa"; String dbPassword = "sa";
DataSource ds = new PooledDataSource(Thread.currentThread().getContextClassLoader(), jdbcDriver, PooledDataSource ds = new PooledDataSource(Thread.currentThread().getContextClassLoader(), jdbcDriver,
jdbcUrl, dbUserName, dbPassword); jdbcUrl, dbUserName, dbPassword);
((PooledDataSource) ds).setPoolTimeToWait(POOL_TIME_TO_WAIT); ds.setPoolTimeToWait(POOL_TIME_TO_WAIT);
((PooledDataSource) ds).forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly ds.forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly
return ds; return ds;
} }
@ -116,11 +105,11 @@ public class TaskanaEngineConfigurationTest {
/** /**
* create data source from properties file. * create data source from properties file.
* *
* @param propertiesFileName * @param propertiesFileName the name of the property file
* @return * @return the parsed datasource.
*/ */
public static DataSource createDataSourceFromProperties(String propertiesFileName) { public static DataSource createDataSourceFromProperties(String propertiesFileName) {
DataSource ds = null; DataSource ds;
try (InputStream input = new FileInputStream(propertiesFileName)) { try (InputStream input = new FileInputStream(propertiesFileName)) {
Properties prop = new Properties(); Properties prop = new Properties();
prop.load(input); prop.load(input);
@ -157,10 +146,6 @@ public class TaskanaEngineConfigurationTest {
ds = createDefaultDataSource(); ds = createDefaultDataSource();
} }
} catch (FileNotFoundException e) {
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
LOGGER.warn("Using default Datasource for Test");
ds = createDefaultDataSource();
} catch (IOException e) { } catch (IOException e) {
LOGGER.warn("createDataSourceFromProperties caught Exception " + e); LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
LOGGER.warn("Using default Datasource for Test"); LOGGER.warn("Using default Datasource for Test");
@ -200,4 +185,15 @@ public class TaskanaEngineConfigurationTest {
return schemaName; return schemaName;
} }
@Test
public void testCreateTaskanaEngine() throws SQLException {
DataSource ds = getDataSource();
TaskanaEngineConfiguration taskEngineConfiguration = new TaskanaEngineConfiguration(ds, false,
TaskanaEngineConfigurationTest.getSchemaName());
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
Assert.assertNotNull(te);
}
} }

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!DOCTYPE module PUBLIC <!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN" "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<!-- <!--
@ -19,116 +19,119 @@
--> -->
<module name="Checker"> <module name="Checker">
<!-- Checks whether files end with a new line. --> <!-- Checks whether files end with a new line. -->
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
<module name="NewlineAtEndOfFile"> <module name="NewlineAtEndOfFile">
<property name="lineSeparator" value="lf_cr_crlf"/> <property name="lineSeparator" value="lf_cr_crlf"/>
</module> </module>
<!-- Checks that property files contain the same keys. --> <!-- Checks that property files contain the same keys. -->
<!-- See http://checkstyle.sf.net/config_misc.html#Translation --> <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
<module name="Translation"/> <module name="Translation"/>
<module name="FileLength"/> <module name="FileLength"/>
<module name="FileTabCharacter"> <module name="FileTabCharacter">
<property name="eachLine" value="true"/> <property name="eachLine" value="true"/>
</module> </module>
<module name="RegexpSingleline"> <module name="RegexpSingleline">
<!-- \s matches whitespace character, $ matches end of line. --> <!-- \s matches whitespace character, $ matches end of line. -->
<property name="format" value="\s+$"/> <property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/> <property name="message" value="Line has trailing spaces."/>
</module> </module>
<module name="TreeWalker"> <module name="TreeWalker">
<property name="cacheFile" value="${checkstyle.cache.file}"/> <property name="cacheFile" value="${checkstyle.cache.file}"/>
<module name="AvoidStarImport"/>
<!-- required for SuppressWarningsFilter (and other Suppress* rules not used here) --> <!-- required for SuppressWarningsFilter (and other Suppress* rules not used here) -->
<!-- see http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder --> <!-- see http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder -->
<module name="SuppressWarningsHolder"/> <module name="SuppressWarningsHolder"/>
<!-- Checks for Javadoc comments. --> <!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html --> <!-- See http://checkstyle.sf.net/config_javadoc.html -->
<module name="JavadocType"/> <module name="JavadocMethod">
<module name="JavadocStyle"/> <property name="allowMissingJavadoc" value="true"/>
</module>
<module name="JavadocType"/>
<module name="JavadocStyle"/>
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<module name="ConstantName"/>
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<!-- Removed because of _ not allowed in test method names -->
<!-- <module name="MethodName"/> -->
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for Naming Conventions. --> <!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_naming.html --> <!-- See http://checkstyle.sf.net/config_import.html -->
<module name="ConstantName"/> <module name="IllegalImport"/> <!-- defaults to sun.* packages -->
<module name="LocalFinalVariableName"/> <module name="RedundantImport"/>
<module name="LocalVariableName"/> <module name="UnusedImports"/>
<module name="MemberName"/>
<!-- Removed because of _ not allowed in test method names -->
<!-- <module name="MethodName"/> -->
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName"/>
<module name="TypeName"/>
<!-- Checks for imports --> <!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_import.html --> <!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="IllegalImport"/> <!-- defaults to sun.* packages --> <module name="EmptyForIteratorPad"/>
<module name="RedundantImport"/> <module name="MethodParamPad"/>
<module name="UnusedImports"/> <module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Checks for whitespace --> <!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_whitespace.html --> <!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="EmptyForIteratorPad"/> <module name="ModifierOrder"/>
<module name="MethodParamPad"/> <module name="RedundantModifier"/>
<module name="NoWhitespaceAfter"/>
<module name="NoWhitespaceBefore"/>
<module name="OperatorWrap"/>
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks --> <!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_modifiers.html --> <!-- See http://checkstyle.sf.net/config_blocks.html -->
<module name="ModifierOrder"/> <module name="AvoidNestedBlocks"/>
<module name="RedundantModifier"/> <module name="EmptyBlock"/>
<module name="LeftCurly"/>
<module name="NeedBraces"/>
<module name="RightCurly"/>
<!-- Checks for blocks. You know, those {}'s --> <!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_blocks.html --> <!-- See http://checkstyle.sf.net/config_coding.html -->
<module name="AvoidNestedBlocks"/> <module name="EmptyStatement"/>
<module name="EmptyBlock"/> <module name="EqualsHashCode"/>
<module name="LeftCurly"/> <module name="IllegalInstantiation"/>
<module name="NeedBraces"/> <module name="InnerAssignment"/>
<module name="RightCurly"/> <module name="MissingSwitchDefault"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for common coding problems --> <!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_coding.html --> <!-- See http://checkstyle.sf.net/config_design.html -->
<module name="EmptyStatement"/> <module name="FinalClass"/>
<module name="EqualsHashCode"/> <module name="HideUtilityClassConstructor"/>
<module name="IllegalInstantiation"/> <module name="InterfaceIsType"/>
<module name="InnerAssignment"/>
<module name="MissingSwitchDefault"/>
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for class design --> <!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_design.html --> <!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="FinalClass"/> <module name="ArrayTypeStyle"/>
<module name="HideUtilityClassConstructor"/> <module name="TodoComment"/>
<module name="InterfaceIsType"/> <module name="UpperEll"/>
<!-- Miscellaneous other checks. --> </module>
<!-- See http://checkstyle.sf.net/config_misc.html -->
<module name="ArrayTypeStyle"/>
<module name="TodoComment"/>
<module name="UpperEll"/>
</module> <!-- Support @SuppressWarnings (added in Checkstyle 5.7) -->
<!-- see http://checkstyle.sourceforge.net/config.html#SuppressWarningsFilter -->
<module name="SuppressWarningsFilter"/>
<!-- Support @SuppressWarnings (added in Checkstyle 5.7) --> <!-- Checks properties file for a duplicated properties. -->
<!-- see http://checkstyle.sourceforge.net/config.html#SuppressWarningsFilter --> <!-- See http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties -->
<module name="SuppressWarningsFilter"/> <module name="UniqueProperties"/>
<!-- Checks properties file for a duplicated properties. -->
<!-- See http://checkstyle.sourceforge.net/config_misc.html#UniqueProperties -->
<module name="UniqueProperties"/>
</module> </module>

View File

@ -1,5 +1,17 @@
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.restdocs.payload.PayloadDocumentation.subsectionWithPath;
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;
@ -17,17 +29,8 @@ 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 static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.documentationConfiguration;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.prettyPrint;
import static org.springframework.restdocs.payload.PayloadDocumentation.*;
import static org.springframework.restdocs.payload.PayloadDocumentation.subsectionWithPath;
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.util.HashMap; import pro.taskana.rest.RestConfiguration;
/** /**
* Generate Rest Docu for AbstractPagingController. * Generate Rest Docu for AbstractPagingController.
@ -36,12 +39,10 @@ import java.util.HashMap;
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT) @SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
public class AbstractPagingControllerRestDocumentation { public class AbstractPagingControllerRestDocumentation {
@LocalServerPort
int port;
@Rule @Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation(); public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
@LocalServerPort
int port;
@Autowired @Autowired
private WebApplicationContext context; private WebApplicationContext context;
@ -54,16 +55,16 @@ public class AbstractPagingControllerRestDocumentation {
@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();
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");
@ -76,30 +77,29 @@ public class AbstractPagingControllerRestDocumentation {
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(), fieldWithPath("_links.self.href").ignored(),
fieldWithPath("_links.self.href").ignored(), fieldWithPath("page").description(pagingFieldDescriptionsMap.get("page")),
fieldWithPath("page").description(pagingFieldDescriptionsMap.get("page")), fieldWithPath("page.size").description(pagingFieldDescriptionsMap.get("page.size")),
fieldWithPath("page.size").description(pagingFieldDescriptionsMap.get("page.size")), fieldWithPath("page.totalElements").description(pagingFieldDescriptionsMap.get("page.totalElements")),
fieldWithPath("page.totalElements").description(pagingFieldDescriptionsMap.get("page.totalElements")), fieldWithPath("page.totalPages").description(pagingFieldDescriptionsMap.get("page.totalPages")),
fieldWithPath("page.totalPages").description(pagingFieldDescriptionsMap.get("page.totalPages")), fieldWithPath("page.number").description(pagingFieldDescriptionsMap.get("page.number")),
fieldWithPath("page.number").description(pagingFieldDescriptionsMap.get("page.number")), fieldWithPath("_links.first.href").description(pagingFieldDescriptionsMap.get("_links.first.href")),
fieldWithPath("_links.first.href").description(pagingFieldDescriptionsMap.get("_links.first.href")), fieldWithPath("_links.last.href").description(pagingFieldDescriptionsMap.get("_links.last.href")),
fieldWithPath("_links.last.href").description(pagingFieldDescriptionsMap.get("_links.last.href")), fieldWithPath("_links.prev.href").description(pagingFieldDescriptionsMap.get("_links.prev.href")),
fieldWithPath("_links.prev.href").description(pagingFieldDescriptionsMap.get("_links.prev.href")), 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
.get("http://127.0.0.1:" + port + "/v1/classifications?page=2&page-size=5") .get("http://127.0.0.1:" + port + "/v1/classifications?page=2&page-size=5")
.header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x")) .header("Authorization", "Basic dGVhbWxlYWRfMTp0ZWFtbGVhZF8x"))
.andExpect(MockMvcResultMatchers.status().isOk()) .andExpect(MockMvcResultMatchers.status().isOk())
.andDo(MockMvcRestDocumentation.document("CommonSummaryResourceFields", .andDo(MockMvcRestDocumentation.document("CommonSummaryResourceFields",
responseFields(pagingFieldDescriptors))); responseFields(pagingFieldDescriptors)));
} }
} }

View File

@ -76,9 +76,7 @@ public abstract class AbstractPagingController {
return pageMetadata; return pageMetadata;
} }
/** // This method is deprecated please remove it after updating taskana-simple-history reference to it.
* This method is deprecated please remove it after updating taskana-simple-history reference to it.
*/
@Deprecated @Deprecated
protected PageMetadata initPageMetadata(String pagesizeParam, String pageParam, long totalElements) protected PageMetadata initPageMetadata(String pagesizeParam, String pageParam, long totalElements)
throws InvalidArgumentException { throws InvalidArgumentException {

View File

@ -7,7 +7,10 @@ import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.ConfigurableBeanFactory; import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.*; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.http.converter.json.SpringHandlerInstantiator; import org.springframework.http.converter.json.SpringHandlerInstantiator;
import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.transaction.annotation.EnableTransactionManagement;