TSK-854: enabled checkstyle javadoc integrity check + fixed issues
This commit is contained in:
parent
7df168d870
commit
7b7ae169b7
|
|
@ -53,6 +53,27 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
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
|
||||
public Classification createClassification(Classification classification)
|
||||
throws ClassificationAlreadyExistException, NotAuthorizedException,
|
||||
|
|
@ -196,7 +217,9 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
/**
|
||||
* 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 {
|
||||
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
|
||||
public Classification getClassification(String id) throws ClassificationNotFoundException {
|
||||
if (id == null) {
|
||||
|
|
@ -343,8 +345,8 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
}
|
||||
} catch (Exception ex) {
|
||||
LOGGER.warn(
|
||||
"Classification-Service throwed Exception while calling mapper and searching for classification. EX={}",
|
||||
ex);
|
||||
"Classification-Service threw Exception while calling mapper and searching for classification. EX={}",
|
||||
ex, ex);
|
||||
}
|
||||
return isExisting;
|
||||
}
|
||||
|
|
@ -433,6 +435,9 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
*
|
||||
* @param classificationImpl the 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(
|
||||
ClassificationImpl classificationImpl)
|
||||
|
|
@ -472,6 +477,8 @@ public class ClassificationServiceImpl implements ClassificationService {
|
|||
*
|
||||
* @param classificationImpl the new classification
|
||||
* @param oldClassification the old classification
|
||||
*
|
||||
* @throws ClassificationNotFoundException if the given classification does not exist.
|
||||
*/
|
||||
private void checkExistenceOfParentClassification(Classification oldClassification,
|
||||
ClassificationImpl classificationImpl)
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ public class TaskanaEngineImpl implements TaskanaEngine {
|
|||
/**
|
||||
* creates the MyBatis transaction factory.
|
||||
*
|
||||
* @param useManagedTransactions
|
||||
* @param useManagedTransactions true, if managed transations should be used. Otherwise false.
|
||||
*/
|
||||
private void createTransactionFactory(boolean useManagedTransactions) {
|
||||
if (useManagedTransactions) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class DBCleaner {
|
|||
/**
|
||||
* Clears the db.
|
||||
*
|
||||
* @param dataSource the datasource
|
||||
* @param dropTables
|
||||
* if true drop tables, else clean tables
|
||||
*/
|
||||
|
|
@ -51,7 +52,7 @@ public class DBCleaner {
|
|||
LOGGER.debug(outWriter.toString());
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,21 +26,10 @@ import pro.taskana.configuration.TaskanaEngineConfiguration;
|
|||
*/
|
||||
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 int POOL_TIME_TO_WAIT = 50;
|
||||
|
||||
@Test
|
||||
public void testCreateTaskanaEngine() throws SQLException {
|
||||
DataSource ds = getDataSource();
|
||||
TaskanaEngineConfiguration taskEngineConfiguration = new TaskanaEngineConfiguration(ds, false,
|
||||
TaskanaEngineConfigurationTest.getSchemaName());
|
||||
|
||||
TaskanaEngine te = taskEngineConfiguration.buildTaskanaEngine();
|
||||
|
||||
Assert.assertNotNull(te);
|
||||
}
|
||||
private static DataSource dataSource = null;
|
||||
private static String schemaName = null;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return
|
||||
* @return the default datasource.
|
||||
*/
|
||||
private static DataSource createDefaultDataSource() {
|
||||
// JdbcDataSource ds = new JdbcDataSource();
|
||||
|
|
@ -81,10 +70,10 @@ public class TaskanaEngineConfigurationTest {
|
|||
String jdbcUrl = "jdbc:h2:mem:taskana;IGNORECASE=TRUE;LOCK_MODE=0";
|
||||
String dbUserName = "sa";
|
||||
String dbPassword = "sa";
|
||||
DataSource ds = new PooledDataSource(Thread.currentThread().getContextClassLoader(), jdbcDriver,
|
||||
PooledDataSource ds = new PooledDataSource(Thread.currentThread().getContextClassLoader(), jdbcDriver,
|
||||
jdbcUrl, dbUserName, dbPassword);
|
||||
((PooledDataSource) ds).setPoolTimeToWait(POOL_TIME_TO_WAIT);
|
||||
((PooledDataSource) ds).forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly
|
||||
ds.setPoolTimeToWait(POOL_TIME_TO_WAIT);
|
||||
ds.forceCloseAll(); // otherwise the MyBatis pool is not initialized correctly
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
|
@ -116,11 +105,11 @@ public class TaskanaEngineConfigurationTest {
|
|||
/**
|
||||
* create data source from properties file.
|
||||
*
|
||||
* @param propertiesFileName
|
||||
* @return
|
||||
* @param propertiesFileName the name of the property file
|
||||
* @return the parsed datasource.
|
||||
*/
|
||||
public static DataSource createDataSourceFromProperties(String propertiesFileName) {
|
||||
DataSource ds = null;
|
||||
DataSource ds;
|
||||
try (InputStream input = new FileInputStream(propertiesFileName)) {
|
||||
Properties prop = new Properties();
|
||||
prop.load(input);
|
||||
|
|
@ -157,10 +146,6 @@ public class TaskanaEngineConfigurationTest {
|
|||
ds = createDefaultDataSource();
|
||||
}
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
|
||||
LOGGER.warn("Using default Datasource for Test");
|
||||
ds = createDefaultDataSource();
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("createDataSourceFromProperties caught Exception " + e);
|
||||
LOGGER.warn("Using default Datasource for Test");
|
||||
|
|
@ -200,4 +185,15 @@ public class TaskanaEngineConfigurationTest {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
<module name="TreeWalker">
|
||||
|
||||
<property name="cacheFile" value="${checkstyle.cache.file}"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
|
||||
<!-- required for SuppressWarningsFilter (and other Suppress* rules not used here) -->
|
||||
<!-- see http://checkstyle.sourceforge.net/config_annotation.html#SuppressWarningsHolder -->
|
||||
|
|
@ -51,10 +52,12 @@
|
|||
|
||||
<!-- Checks for Javadoc comments. -->
|
||||
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
|
||||
<module name="JavadocMethod">
|
||||
<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"/>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,17 @@
|
|||
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.Rule;
|
||||
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.setup.MockMvcBuilders;
|
||||
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.
|
||||
|
|
@ -36,12 +39,10 @@ import java.util.HashMap;
|
|||
@SpringBootTest(classes = RestConfiguration.class, webEnvironment = WebEnvironment.RANDOM_PORT)
|
||||
public class AbstractPagingControllerRestDocumentation {
|
||||
|
||||
@LocalServerPort
|
||||
int port;
|
||||
|
||||
@Rule
|
||||
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation();
|
||||
|
||||
@LocalServerPort
|
||||
int port;
|
||||
@Autowired
|
||||
private WebApplicationContext context;
|
||||
|
||||
|
|
@ -76,7 +77,6 @@ public class AbstractPagingControllerRestDocumentation {
|
|||
pagingFieldDescriptionsMap.put("_links.next.href", "Link to next page");
|
||||
|
||||
pagingFieldDescriptors = new FieldDescriptor[] {
|
||||
|
||||
subsectionWithPath("_embedded.classificationSummaryResourceList").ignored(),
|
||||
fieldWithPath("_links").ignored(),
|
||||
fieldWithPath("_links.self").ignored(),
|
||||
|
|
|
|||
|
|
@ -76,9 +76,7 @@ public abstract class AbstractPagingController {
|
|||
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
|
||||
protected PageMetadata initPageMetadata(String pagesizeParam, String pageParam, long totalElements)
|
||||
throws InvalidArgumentException {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,10 @@ import javax.sql.DataSource;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
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.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue