TSK-1009: Fix building errors after checkstyle changes

This commit is contained in:
Benjamin Eckstein 2020-01-07 15:06:43 +01:00 committed by Mustapha Zorgati
parent 841d38961a
commit c4cd616e35
22 changed files with 269 additions and 300 deletions

View File

@ -3,9 +3,8 @@ package pro.taskana.simplehistory.query;
import pro.taskana.QueryColumnName; import pro.taskana.QueryColumnName;
/** /**
* Enum containing the column names for @see * Enum containing the column names for {@see
* pro.taskana.simplehistory.mappings.HistoryQueryMapper#queryHistoryColumnValues * pro.taskana.simplehistory.impl.mappings.HistoryQueryMapper#queryHistoryColumnValues}.
* (pro.taskana.simplehistory.impl.HistoryQueryImpl).
* *
* @author bv * @author bv
*/ */

View File

@ -1,8 +1,8 @@
package pro.taskana; package pro.taskana;
/** /**
* Enum containing the column names for {@see * Enum containing the column names for
* pro.taskana.mappings.QueryMapper#queryWorkbasketAccessItemColumnValues}. * {@link pro.taskana.mappings.QueryMapper#queryWorkbasketAccessItemColumnValues}.
* *
* @author jsa * @author jsa
*/ */

View File

@ -1,8 +1,8 @@
package pro.taskana; package pro.taskana;
/** /**
* Enum containing the column names for {@see * Enum containing the column names for
* pro.taskana.mappings.QueryMapper#queryClassificationColumnValues}. * {@link pro.taskana.mappings.QueryMapper#queryClassificationColumnValues}.
* *
* @author jsa * @author jsa
*/ */

View File

@ -33,26 +33,23 @@ public class KeyDomain {
this.domain = domain; this.domain = domain;
} }
@Override
public int hashCode() {
return Objects.hash(key, domain);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof KeyDomain)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
KeyDomain other = (KeyDomain) obj; KeyDomain other = (KeyDomain) obj;
return Objects.equals(key, other.key) && Objects.equals(domain, other.domain); return Objects.equals(key, other.key) && Objects.equals(domain, other.domain);
} }
@Override
public int hashCode() {
return Objects.hash(key, domain);
}
@Override @Override
public String toString() { public String toString() {
return "KeyDomain [key=" + key + ", domain=" + domain + "]"; return "KeyDomain [key=" + key + ", domain=" + domain + "]";

View File

@ -60,20 +60,12 @@ public class ObjectReference {
this.value = value; this.value = value;
} }
@Override
public int hashCode() {
return Objects.hash(id, company, system, systemInstance, type, value);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof ObjectReference)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
ObjectReference other = (ObjectReference) obj; ObjectReference other = (ObjectReference) obj;
@ -85,6 +77,11 @@ public class ObjectReference {
&& Objects.equals(value, other.value); && Objects.equals(value, other.value);
} }
@Override
public int hashCode() {
return Objects.hash(id, company, system, systemInstance, type, value);
}
@Override @Override
public String toString() { public String toString() {
return "ObjectReference [" return "ObjectReference ["

View File

@ -1,8 +1,8 @@
package pro.taskana; package pro.taskana;
/** /**
* Enum containing the column names for @see * Enum containing the column names for
* pro.taskana.mappings.QueryMapper#queryTaskColumnValues(pro.taskana.impl.TaskQueryImpl). * {@link pro.taskana.mappings.QueryMapper#queryTaskColumnValues(pro.taskana.impl.TaskQueryImpl)}.
* *
* @author jsa * @author jsa
*/ */

View File

@ -52,26 +52,23 @@ public class TimeInterval {
this.end = end; this.end = end;
} }
@Override
public int hashCode() {
return Objects.hash(begin, end);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof TimeInterval)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
TimeInterval other = (TimeInterval) obj; TimeInterval other = (TimeInterval) obj;
return Objects.equals(begin, other.begin) && Objects.equals(end, other.end); return Objects.equals(begin, other.begin) && Objects.equals(end, other.end);
} }
@Override
public int hashCode() {
return Objects.hash(begin, end);
}
@Override @Override
public String toString() { public String toString() {
return "TimeInterval [" + "begin=" + this.begin + ", end=" + this.end + "]"; return "TimeInterval [" + "begin=" + this.begin + ", end=" + this.end + "]";

View File

@ -1,7 +1,7 @@
package pro.taskana; package pro.taskana;
/** /**
* Enum containing the column names for @see {@link * Enum containing the column names for {@link
* pro.taskana.mappings.QueryMapper#queryWorkbasketColumnValues * pro.taskana.mappings.QueryMapper#queryWorkbasketColumnValues
* (pro.taskana.impl.WorkbasketQueryImpl)}. * (pro.taskana.impl.WorkbasketQueryImpl)}.
* *

View File

@ -161,10 +161,7 @@ public class AttachmentImpl implements Attachment {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof AttachmentImpl)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
AttachmentImpl other = (AttachmentImpl) obj; AttachmentImpl other = (AttachmentImpl) obj;

View File

@ -122,34 +122,12 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
this.classificationSummary = classificationSummary; this.classificationSummary = classificationSummary;
} }
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getReceived()
*/
@Override
public Instant getReceived() {
return received;
}
public void setReceived(Instant received) {
this.received = received;
}
@Override
public int hashCode() {
return Objects.hash(
id, taskId, created, modified, classificationSummary, objectReference, channel, received);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof AttachmentSummaryImpl)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
AttachmentSummaryImpl other = (AttachmentSummaryImpl) obj; AttachmentSummaryImpl other = (AttachmentSummaryImpl) obj;
@ -163,6 +141,25 @@ public class AttachmentSummaryImpl implements AttachmentSummary {
&& Objects.equals(received, other.received); && Objects.equals(received, other.received);
} }
@Override
public int hashCode() {
return Objects.hash(
id, taskId, created, modified, classificationSummary, objectReference, channel, received);
}
/*
* (non-Javadoc)
* @see pro.taskana.impl.AttachmentSummary#getReceived()
*/
@Override
public Instant getReceived() {
return received;
}
public void setReceived(Instant received) {
this.received = received;
}
@Override @Override
public String toString() { public String toString() {
return "AttachmentSummaryImpl [id=" return "AttachmentSummaryImpl [id="

View File

@ -119,21 +119,12 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla
return (other instanceof ClassificationImpl); return (other instanceof ClassificationImpl);
} }
@Override
public int hashCode() {
return Objects.hash(
super.hashCode(), isValidInDomain, created, modified, description, applicationEntryPoint);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof ClassificationImpl)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
if (!super.equals(obj)) { if (!super.equals(obj)) {
@ -147,6 +138,12 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla
&& Objects.equals(applicationEntryPoint, other.applicationEntryPoint); && Objects.equals(applicationEntryPoint, other.applicationEntryPoint);
} }
@Override
public int hashCode() {
return Objects.hash(
super.hashCode(), isValidInDomain, created, modified, description, applicationEntryPoint);
}
@Override @Override
public String toString() { public String toString() {
return "ClassificationImpl [id=" return "ClassificationImpl [id="

View File

@ -190,8 +190,38 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
this.custom8 = custom8; this.custom8 = custom8;
} }
protected boolean canEqual(Object other) { @Override
return (other instanceof ClassificationSummaryImpl); public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ClassificationSummaryImpl)) {
return false;
}
ClassificationSummaryImpl other = (ClassificationSummaryImpl) obj;
if (!other.canEqual(this)) {
return false;
}
return priority == other.priority
&& Objects.equals(id, other.id)
&& Objects.equals(key, other.key)
&& Objects.equals(category, other.category)
&& Objects.equals(type, other.type)
&& Objects.equals(domain, other.domain)
&& Objects.equals(name, other.name)
&& Objects.equals(parentId, other.parentId)
&& Objects.equals(parentKey, other.parentKey)
&& Objects.equals(serviceLevel, other.serviceLevel)
&& Objects.equals(custom1, other.custom1)
&& Objects.equals(custom2, other.custom2)
&& Objects.equals(custom3, other.custom3)
&& Objects.equals(custom4, other.custom4)
&& Objects.equals(custom5, other.custom5)
&& Objects.equals(custom6, other.custom6)
&& Objects.equals(custom7, other.custom7)
&& Objects.equals(custom8, other.custom8);
} }
@Override @Override
@ -217,36 +247,8 @@ public class ClassificationSummaryImpl implements ClassificationSummary {
custom8); custom8);
} }
@Override protected boolean canEqual(Object other) {
public boolean equals(Object obj) { return (other instanceof ClassificationSummaryImpl);
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ClassificationSummaryImpl other = (ClassificationSummaryImpl) obj;
return priority == other.priority
&& Objects.equals(id, other.id)
&& Objects.equals(key, other.key)
&& Objects.equals(category, other.category)
&& Objects.equals(type, other.type)
&& Objects.equals(domain, other.domain)
&& Objects.equals(name, other.name)
&& Objects.equals(parentId, other.parentId)
&& Objects.equals(parentKey, other.parentKey)
&& Objects.equals(serviceLevel, other.serviceLevel)
&& Objects.equals(custom1, other.custom1)
&& Objects.equals(custom2, other.custom2)
&& Objects.equals(custom3, other.custom3)
&& Objects.equals(custom4, other.custom4)
&& Objects.equals(custom5, other.custom5)
&& Objects.equals(custom6, other.custom6)
&& Objects.equals(custom7, other.custom7)
&& Objects.equals(custom8, other.custom8);
} }
@Override @Override

View File

@ -720,62 +720,12 @@ public class TaskImpl implements Task {
return result; return result;
} }
@Override
public int hashCode() {
return Objects.hash(
id,
externalId,
created,
claimed,
completed,
modified,
planned,
due,
name,
creator,
description,
note,
priority,
state,
classificationSummary,
workbasketSummary,
businessProcessId,
parentBusinessProcessId,
owner,
primaryObjRef,
isRead,
isTransferred,
customAttributes,
callbackInfo,
callbackState,
attachments,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8,
custom9,
custom10,
custom11,
custom12,
custom13,
custom14,
custom15,
custom16);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof TaskImpl)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
TaskImpl other = (TaskImpl) obj; TaskImpl other = (TaskImpl) obj;
@ -823,6 +773,53 @@ public class TaskImpl implements Task {
&& Objects.equals(custom16, other.custom16); && Objects.equals(custom16, other.custom16);
} }
@Override
public int hashCode() {
return Objects.hash(
id,
externalId,
created,
claimed,
completed,
modified,
planned,
due,
name,
creator,
description,
note,
priority,
state,
classificationSummary,
workbasketSummary,
businessProcessId,
parentBusinessProcessId,
owner,
primaryObjRef,
isRead,
isTransferred,
customAttributes,
callbackInfo,
callbackState,
attachments,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8,
custom9,
custom10,
custom11,
custom12,
custom13,
custom14,
custom15,
custom16);
}
@Override @Override
public String toString() { public String toString() {
return "TaskImpl [id=" return "TaskImpl [id="

View File

@ -588,58 +588,12 @@ public class TaskSummaryImpl implements TaskSummary {
this.custom16 = custom16; this.custom16 = custom16;
} }
@Override
public int hashCode() {
return Objects.hash(
taskId,
externalId,
created,
claimed,
completed,
modified,
planned,
due,
name,
creator,
note,
priority,
state,
classificationSummary,
workbasketSummary,
businessProcessId,
parentBusinessProcessId,
owner,
primaryObjRef,
isRead,
isTransferred,
attachmentSummaries,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8,
custom9,
custom10,
custom11,
custom12,
custom13,
custom14,
custom15,
custom16);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof TaskSummaryImpl)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
TaskSummaryImpl other = (TaskSummaryImpl) obj; TaskSummaryImpl other = (TaskSummaryImpl) obj;
@ -683,6 +637,49 @@ public class TaskSummaryImpl implements TaskSummary {
&& Objects.equals(custom16, other.custom16); && Objects.equals(custom16, other.custom16);
} }
@Override
public int hashCode() {
return Objects.hash(
taskId,
externalId,
created,
claimed,
completed,
modified,
planned,
due,
name,
creator,
note,
priority,
state,
classificationSummary,
workbasketSummary,
businessProcessId,
parentBusinessProcessId,
owner,
primaryObjRef,
isRead,
isTransferred,
attachmentSummaries,
custom1,
custom2,
custom3,
custom4,
custom5,
custom6,
custom7,
custom8,
custom9,
custom10,
custom11,
custom12,
custom13,
custom14,
custom15,
custom16);
}
@Override @Override
public String toString() { public String toString() {
return "TaskSummaryImpl [taskId=" return "TaskSummaryImpl [taskId="

View File

@ -415,42 +415,12 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
this.permCustom12 = permCustom12; this.permCustom12 = permCustom12;
} }
@Override
public int hashCode() {
return Objects.hash(
id,
workbasketId,
workbasketKey,
accessId,
accessName,
permRead,
permOpen,
permAppend,
permTransfer,
permDistribute,
permCustom1,
permCustom2,
permCustom3,
permCustom4,
permCustom5,
permCustom6,
permCustom7,
permCustom8,
permCustom9,
permCustom10,
permCustom11,
permCustom12);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof WorkbasketAccessItemImpl)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
WorkbasketAccessItemImpl other = (WorkbasketAccessItemImpl) obj; WorkbasketAccessItemImpl other = (WorkbasketAccessItemImpl) obj;
@ -478,6 +448,33 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem {
&& Objects.equals(accessName, other.accessName); && Objects.equals(accessName, other.accessName);
} }
@Override
public int hashCode() {
return Objects.hash(
id,
workbasketId,
workbasketKey,
accessId,
accessName,
permRead,
permOpen,
permAppend,
permTransfer,
permDistribute,
permCustom1,
permCustom2,
permCustom3,
permCustom4,
permCustom5,
permCustom6,
permCustom7,
permCustom8,
permCustom9,
permCustom10,
permCustom11,
permCustom12);
}
@Override @Override
public String toString() { public String toString() {
return "WorkbasketAccessItem [id=" return "WorkbasketAccessItem [id="

View File

@ -228,38 +228,12 @@ public class WorkbasketImpl implements Workbasket {
return result; return result;
} }
@Override
public int hashCode() {
return Objects.hash(
id,
key,
created,
modified,
name,
description,
owner,
domain,
type,
custom1,
custom2,
custom3,
custom4,
orgLevel1,
orgLevel2,
orgLevel3,
orgLevel4,
markedForDeletion);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof WorkbasketImpl)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
WorkbasketImpl other = (WorkbasketImpl) obj; WorkbasketImpl other = (WorkbasketImpl) obj;
@ -283,6 +257,29 @@ public class WorkbasketImpl implements Workbasket {
&& Objects.equals(orgLevel4, other.orgLevel4); && Objects.equals(orgLevel4, other.orgLevel4);
} }
@Override
public int hashCode() {
return Objects.hash(
id,
key,
created,
modified,
name,
description,
owner,
domain,
type,
custom1,
custom2,
custom3,
custom4,
orgLevel1,
orgLevel2,
orgLevel3,
orgLevel4,
markedForDeletion);
}
@Override @Override
public String toString() { public String toString() {
return "WorkbasketImpl [id=" return "WorkbasketImpl [id="

View File

@ -231,36 +231,12 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
this.markedForDeletion = markedForDeletion; this.markedForDeletion = markedForDeletion;
} }
@Override
public int hashCode() {
return Objects.hash(
id,
key,
name,
description,
owner,
domain,
type,
custom1,
custom2,
custom3,
custom4,
orgLevel1,
orgLevel2,
orgLevel3,
orgLevel4,
markedForDeletion);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {
return true; return true;
} }
if (obj == null) { if (!(obj instanceof WorkbasketSummaryImpl)) {
return false;
}
if (getClass() != obj.getClass()) {
return false; return false;
} }
WorkbasketSummaryImpl other = (WorkbasketSummaryImpl) obj; WorkbasketSummaryImpl other = (WorkbasketSummaryImpl) obj;
@ -282,6 +258,27 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary {
&& Objects.equals(orgLevel4, other.orgLevel4); && Objects.equals(orgLevel4, other.orgLevel4);
} }
@Override
public int hashCode() {
return Objects.hash(
id,
key,
name,
description,
owner,
domain,
type,
custom1,
custom2,
custom3,
custom4,
orgLevel1,
orgLevel2,
orgLevel3,
orgLevel4,
markedForDeletion);
}
@Override @Override
public String toString() { public String toString() {
return "WorkbasketSummaryImpl [id=" return "WorkbasketSummaryImpl [id="

View File

@ -92,7 +92,7 @@ public class SampleDataGenerator {
try (Connection connection = dataSource.getConnection()) { try (Connection connection = dataSource.getConnection()) {
connection.setSchema(schema); connection.setSchema(schema);
SqlRunner runner = new SqlRunner(connection); SqlRunner runner = new SqlRunner(connection);
String tableSafe = SQLReplacer.getSanitizedTableName(table); String tableSafe = SqlReplacer.getSanitizedTableName(table);
String query = "SELECT 1 FROM " + tableSafe + " LIMIT 1;"; String query = "SELECT 1 FROM " + tableSafe + " LIMIT 1;";
runner.run(query); runner.run(query);
return true; return true;
@ -105,7 +105,7 @@ public class SampleDataGenerator {
try (Connection connection = dataSource.getConnection()) { try (Connection connection = dataSource.getConnection()) {
String dbProductName = connection.getMetaData().getDatabaseProductName(); String dbProductName = connection.getMetaData().getDatabaseProductName();
return scripts return scripts
.map(script -> SQLReplacer.getScriptAsSql(dbProductName, now, script)) .map(script -> SqlReplacer.getScriptAsSql(dbProductName, now, script))
.collect(Collectors.toList()); .collect(Collectors.toList());
} catch (SQLException e) { } catch (SQLException e) {
throw new RuntimeSqlException("Connection to database failed.", e); throw new RuntimeSqlException("Connection to database failed.", e);

View File

@ -11,20 +11,21 @@ import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** This class replaces boolean values with int values if the database is db2. */ /** This class replaces boolean values with int values if the database is db2. */
final class SQLReplacer { final class SqlReplacer {
static final String RELATIVE_DATE_REGEX = "RELATIVE_DATE\\((-?\\d+)\\)"; static final String RELATIVE_DATE_REGEX = "RELATIVE_DATE\\((-?\\d+)\\)";
static final Pattern RELATIVE_DATE_PATTERN = Pattern.compile(RELATIVE_DATE_REGEX); static final Pattern RELATIVE_DATE_PATTERN = Pattern.compile(RELATIVE_DATE_REGEX);
static final DateTimeFormatter DATE_TIME_FORMATTER = static final DateTimeFormatter DATE_TIME_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS"); DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS");
private SQLReplacer() {} private SqlReplacer() {
}
static String getScriptAsSql(String dbProductName, LocalDateTime now, String scriptPath) { static String getScriptAsSql(String dbProductName, LocalDateTime now, String scriptPath) {
return parseAndReplace(getScriptBufferedStream(scriptPath), now, dbProductName); return parseAndReplace(getScriptBufferedStream(scriptPath), now, dbProductName);
} }
static boolean isPostgreSQL(String databaseProductName) { static boolean isPostgreSql(String databaseProductName) {
return "PostgreSQL".equals(databaseProductName); return "PostgreSQL".equals(databaseProductName);
} }

View File

@ -21,7 +21,7 @@ class SampleDataProviderTest {
@Test @Test
void getScriptsFileExists() { void getScriptsFileExists() {
SampleDataProvider.getDefaultScripts() SampleDataProvider.getDefaultScripts()
.map(SQLReplacer::getScriptBufferedStream) .map(SqlReplacer::getScriptBufferedStream)
.forEach(Assertions::assertNotNull); .forEach(Assertions::assertNotNull);
} }
} }

View File

@ -1,8 +1,8 @@
package pro.taskana.sampledata; package pro.taskana.sampledata;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static pro.taskana.sampledata.SQLReplacer.DATE_TIME_FORMATTER; import static pro.taskana.sampledata.SqlReplacer.DATE_TIME_FORMATTER;
import static pro.taskana.sampledata.SQLReplacer.RELATIVE_DATE_PATTERN; import static pro.taskana.sampledata.SqlReplacer.RELATIVE_DATE_PATTERN;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@ -11,13 +11,13 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
/** Test SampleDataGenerator. */ /** Test SampleDataGenerator. */
class SQLReplacerTest { class SqlReplacerTest {
@Test @Test
void replaceRelativeTimeFunctionSameDate() { void replaceRelativeTimeFunctionSameDate() {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String dateFormatted = now.format(DATE_TIME_FORMATTER); String dateFormatted = now.format(DATE_TIME_FORMATTER);
String sqlStringReplaced = SQLReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(0) ..."); String sqlStringReplaced = SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(0) ...");
assertThat(sqlStringReplaced, CoreMatchers.containsString(dateFormatted)); assertThat(sqlStringReplaced, CoreMatchers.containsString(dateFormatted));
} }
@ -47,7 +47,7 @@ class SQLReplacerTest {
void replaceRelativeTimeFunctionPosDate() { void replaceRelativeTimeFunctionPosDate() {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String dateFormatted = now.plusDays(5).format(DATE_TIME_FORMATTER); String dateFormatted = now.plusDays(5).format(DATE_TIME_FORMATTER);
String sqlStringReplaced = SQLReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(5) ..."); String sqlStringReplaced = SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(5) ...");
assertThat(sqlStringReplaced, CoreMatchers.containsString(dateFormatted)); assertThat(sqlStringReplaced, CoreMatchers.containsString(dateFormatted));
} }
@ -56,7 +56,7 @@ class SQLReplacerTest {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String dateFormatted = now.plusDays(-10).format(DATE_TIME_FORMATTER); String dateFormatted = now.plusDays(-10).format(DATE_TIME_FORMATTER);
String sqlStringReplaced = String sqlStringReplaced =
SQLReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(-10) ..."); SqlReplacer.replaceDatePlaceholder(now, "... RELATIVE_DATE(-10) ...");
assertThat(sqlStringReplaced, CoreMatchers.containsString(dateFormatted)); assertThat(sqlStringReplaced, CoreMatchers.containsString(dateFormatted));
} }
} }

View File

@ -3,6 +3,7 @@ package pro.taskana.rest;
/** Collection of Url to Controller mappings. */ /** Collection of Url to Controller mappings. */
public final class Mapping { public final class Mapping {
private static final String PRE = "/api/v1/";
public static final String URL_ACCESSID = PRE + "access-ids"; public static final String URL_ACCESSID = PRE + "access-ids";
public static final String URL_ACCESSID_GROUPS = URL_ACCESSID + "/groups"; public static final String URL_ACCESSID_GROUPS = URL_ACCESSID + "/groups";
public static final String URL_CLASSIFICATIONS = PRE + "classifications"; public static final String URL_CLASSIFICATIONS = PRE + "classifications";
@ -39,7 +40,6 @@ public final class Mapping {
public static final String URL_WORKBASKET_DISTRIBUTION_ID = public static final String URL_WORKBASKET_DISTRIBUTION_ID =
URL_WORKBASKET + "/distribution-targets/{workbasketId}"; URL_WORKBASKET + "/distribution-targets/{workbasketId}";
public static final String URL_WORKBASKETDEFIITIONS = PRE + "workbasket-definitions"; public static final String URL_WORKBASKETDEFIITIONS = PRE + "workbasket-definitions";
private static final String PRE = "/api/v1/";
private Mapping() {} private Mapping() {}
} }