TSK-276 Classification.CREATE in the schema should be a Timestamp rather than a Date

This commit is contained in:
BerndBreier 2018-02-15 12:09:00 +01:00 committed by Holger Hagen
parent 6a644b7db2
commit 28e13608b1
10 changed files with 70 additions and 160 deletions

View File

@ -1,7 +1,5 @@
package pro.taskana; package pro.taskana;
import java.time.Instant;
/** /**
* ClassificationQuery for generating dynamic sql. * ClassificationQuery for generating dynamic sql.
*/ */
@ -64,11 +62,11 @@ public interface ClassificationQuery extends BaseQuery<ClassificationSummary> {
/** /**
* Add your created-Dates to your query. * Add your created-Dates to your query.
* *
* @param created * @param createdIn
* date (as instant) of classification creation. * the {@link TimeInterval} within which the searched-for classifications were created.
* @return the query * @return the query
*/ */
ClassificationQuery created(Instant... created); ClassificationQuery createdWithin(TimeInterval... createdIn);
/** /**
* Add your name to your query. * Add your name to your query.

View File

@ -338,8 +338,7 @@ public interface TaskService {
* @return the result of the operations with Id and Exception for each failed task completion. * @return the result of the operations with Id and Exception for each failed task completion.
* @throws InvalidArgumentException * @throws InvalidArgumentException
* If the taskId parameter is NULL. * If the taskId parameter is NULL.
* @throws NotAuthorizedException
*/ */
BulkOperationResults<String, TaskanaException> completeTasks(List<String> taskIds) BulkOperationResults<String, TaskanaException> completeTasks(List<String> taskIds)
throws InvalidArgumentException, NotAuthorizedException; throws InvalidArgumentException;
} }

View File

@ -28,7 +28,11 @@ public class TimeInterval {
} }
public boolean isValid() { public boolean isValid() {
return begin != null || end != null; boolean isValid = begin != null || end != null;
if (begin != null && end != null && begin.isAfter(end)) {
isValid = false;
}
return isValid;
} }
public Instant getBegin() { public Instant getBegin() {

View File

@ -1,6 +1,5 @@
package pro.taskana.impl; package pro.taskana.impl;
import java.time.Instant;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -12,6 +11,7 @@ import org.slf4j.LoggerFactory;
import pro.taskana.ClassificationQuery; import pro.taskana.ClassificationQuery;
import pro.taskana.ClassificationSummary; import pro.taskana.ClassificationSummary;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.TimeInterval;
import pro.taskana.exceptions.TaskanaRuntimeException; import pro.taskana.exceptions.TaskanaRuntimeException;
import pro.taskana.impl.util.LoggerUtils; import pro.taskana.impl.util.LoggerUtils;
@ -32,10 +32,10 @@ public class ClassificationQueryImpl implements ClassificationQuery {
private String[] type; private String[] type;
private String[] domain; private String[] domain;
private Boolean validInDomain; private Boolean validInDomain;
private Instant[] created; private TimeInterval[] createdIn;
private String[] nameIn; private String[] nameIn;
private String[] nameLike; private String[] nameLike;
private String description; private String descriptionLike;
private int[] priority; private int[] priority;
private String[] serviceLevelIn; private String[] serviceLevelIn;
private String[] serviceLevelLike; private String[] serviceLevelLike;
@ -99,8 +99,13 @@ public class ClassificationQueryImpl implements ClassificationQuery {
} }
@Override @Override
public ClassificationQuery created(Instant... created) { public ClassificationQuery createdWithin(TimeInterval... createdIn) {
this.created = created; this.createdIn = createdIn;
for (TimeInterval ti : createdIn) {
if (!ti.isValid()) {
throw new IllegalArgumentException("TimeInterval " + ti + " is invalid.");
}
}
return this; return this;
} }
@ -118,7 +123,7 @@ public class ClassificationQueryImpl implements ClassificationQuery {
@Override @Override
public ClassificationQuery descriptionLike(String description) { public ClassificationQuery descriptionLike(String description) {
this.description = description; this.descriptionLike = description;
return this; return this;
} }
@ -313,250 +318,126 @@ public class ClassificationQueryImpl implements ClassificationQuery {
return key; return key;
} }
public void setKey(String[] key) {
this.key = key;
}
public String[] getParentClassificationKey() { public String[] getParentClassificationKey() {
return parentClassificationKey; return parentClassificationKey;
} }
public void setParentClassificationKey(String[] parentClassificationKey) {
this.parentClassificationKey = parentClassificationKey;
}
public String[] getCategory() { public String[] getCategory() {
return category; return category;
} }
public void setCategory(String[] category) {
this.category = category;
}
public String[] getType() { public String[] getType() {
return type; return type;
} }
public void setType(String[] type) {
this.type = type;
}
public String[] getNameIn() { public String[] getNameIn() {
return nameIn; return nameIn;
} }
public void setNameIn(String[] nameIn) {
this.nameIn = nameIn;
}
public String[] getNameLike() { public String[] getNameLike() {
return nameLike; return nameLike;
} }
public void setNameLike(String[] nameLike) {
this.nameLike = nameLike;
}
public String getDescriptionLike() { public String getDescriptionLike() {
return description; return descriptionLike;
}
public void setDescriptionLike(String description) {
this.description = description;
} }
public int[] getPriority() { public int[] getPriority() {
return priority; return priority;
} }
public void setPriority(int[] priority) {
this.priority = priority;
}
public String[] getServiceLevelIn() { public String[] getServiceLevelIn() {
return serviceLevelIn; return serviceLevelIn;
} }
public void setServiceLevelIn(String[] serviceLevel) {
this.serviceLevelIn = serviceLevel;
}
public String[] getServiceLevelLike() { public String[] getServiceLevelLike() {
return serviceLevelLike; return serviceLevelLike;
} }
public void setServiceLevelLike(String[] serviceLevelLike) {
this.serviceLevelLike = serviceLevelLike;
}
public String[] getDomain() { public String[] getDomain() {
return domain; return domain;
} }
public void setDomain(String[] domain) {
this.domain = domain;
}
public Boolean getValidInDomain() { public Boolean getValidInDomain() {
return validInDomain; return validInDomain;
} }
public void setValidInDomain(Boolean validInDomain) { public TimeInterval[] getCreatedIn() {
this.validInDomain = validInDomain; return createdIn;
}
public Instant[] getCreated() {
return created;
}
public void setCreated(Instant[] created) {
this.created = created;
} }
public String[] getApplicationEntryPointIn() { public String[] getApplicationEntryPointIn() {
return applicationEntryPointIn; return applicationEntryPointIn;
} }
public void setApplicationEntryPointIn(String[] applicationEntryPoint) {
this.applicationEntryPointIn = applicationEntryPoint;
}
public String[] getApplicationEntryPointLike() { public String[] getApplicationEntryPointLike() {
return applicationEntryPointLike; return applicationEntryPointLike;
} }
public void setApplicationEntryPointLike(String[] applicationEntryPoint) {
this.applicationEntryPointLike = applicationEntryPoint;
}
public String[] getCustom1In() { public String[] getCustom1In() {
return custom1In; return custom1In;
} }
public void setCustom1In(String[] custom1In) {
this.custom1In = custom1In;
}
public String[] getCustom1Like() { public String[] getCustom1Like() {
return custom1Like; return custom1Like;
} }
public void setCustom1Like(String[] custom1Like) {
this.custom1Like = custom1Like;
}
public String[] getCustom2In() { public String[] getCustom2In() {
return custom2In; return custom2In;
} }
public void setCustom2In(String[] custom2In) {
this.custom2In = custom2In;
}
public String[] getCustom2Like() { public String[] getCustom2Like() {
return custom2Like; return custom2Like;
} }
public void setCustom2Like(String[] custom2Like) {
this.custom2Like = custom2Like;
}
public String[] getCustom3In() { public String[] getCustom3In() {
return custom3In; return custom3In;
} }
public void setCustom3In(String[] custom3In) {
this.custom3In = custom3In;
}
public String[] getCustom3Like() { public String[] getCustom3Like() {
return custom3Like; return custom3Like;
} }
public void setCustom3Like(String[] custom3Like) {
this.custom3Like = custom3Like;
}
public String[] getCustom4In() { public String[] getCustom4In() {
return custom4In; return custom4In;
} }
public void setCustom4In(String[] custom4In) {
this.custom4In = custom4In;
}
public String[] getCustom4Like() { public String[] getCustom4Like() {
return custom4Like; return custom4Like;
} }
public void setCustom4Like(String[] custom4Like) {
this.custom4Like = custom4Like;
}
public String[] getCustom5In() { public String[] getCustom5In() {
return custom5In; return custom5In;
} }
public void setCustom5In(String[] custom5In) {
this.custom5In = custom5In;
}
public String[] getCustom5Like() { public String[] getCustom5Like() {
return custom5Like; return custom5Like;
} }
public void setCustom5Like(String[] custom5Like) {
this.custom5Like = custom5Like;
}
public String[] getCustom6In() { public String[] getCustom6In() {
return custom6In; return custom6In;
} }
public void setCustom6In(String[] custom6In) {
this.custom6In = custom6In;
}
public String[] getCustom6Like() { public String[] getCustom6Like() {
return custom6Like; return custom6Like;
} }
public void setCustom6Like(String[] custom6Like) {
this.custom6Like = custom6Like;
}
public String[] getCustom7In() { public String[] getCustom7In() {
return custom7In; return custom7In;
} }
public void setCustom7In(String[] custom7In) {
this.custom7In = custom7In;
}
public String[] getCustom7Like() { public String[] getCustom7Like() {
return custom7Like; return custom7Like;
} }
public void setCustom7Like(String[] custom7Like) {
this.custom7Like = custom7Like;
}
public String[] getCustom8In() { public String[] getCustom8In() {
return custom8In; return custom8In;
} }
public void setCustom8In(String[] custom8In) {
this.custom8In = custom8In;
}
public String[] getCustom8Like() { public String[] getCustom8Like() {
return custom8Like; return custom8Like;
} }
public void setCustom8Like(String[] custom8Like) {
this.custom8Like = custom8Like;
}
@Override @Override
public long count() { public long count() {
LOGGER.debug("entry to count(), this = {}", this); LOGGER.debug("entry to count(), this = {}", this);
@ -574,8 +455,8 @@ public class ClassificationQueryImpl implements ClassificationQuery {
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("ClassificationQueryImpl [taskanaEngineImpl="); builder.append("ClassificationQueryImpl [key=");
builder.append(taskanaEngineImpl); builder.append(Arrays.toString(key));
builder.append(", parentClassificationKey="); builder.append(", parentClassificationKey=");
builder.append(Arrays.toString(parentClassificationKey)); builder.append(Arrays.toString(parentClassificationKey));
builder.append(", category="); builder.append(", category=");
@ -586,14 +467,14 @@ public class ClassificationQueryImpl implements ClassificationQuery {
builder.append(Arrays.toString(domain)); builder.append(Arrays.toString(domain));
builder.append(", validInDomain="); builder.append(", validInDomain=");
builder.append(validInDomain); builder.append(validInDomain);
builder.append(", created="); builder.append(", createdIn=");
builder.append(Arrays.toString(created)); builder.append(Arrays.toString(createdIn));
builder.append(", nameIn="); builder.append(", nameIn=");
builder.append(Arrays.toString(nameIn)); builder.append(Arrays.toString(nameIn));
builder.append(", nameLike="); builder.append(", nameLike=");
builder.append(Arrays.toString(nameLike)); builder.append(Arrays.toString(nameLike));
builder.append(", descriptionLike="); builder.append(", descriptionLike=");
builder.append(description); builder.append(descriptionLike);
builder.append(", priority="); builder.append(", priority=");
builder.append(Arrays.toString(priority)); builder.append(Arrays.toString(priority));
builder.append(", serviceLevelIn="); builder.append(", serviceLevelIn=");
@ -639,4 +520,5 @@ public class ClassificationQueryImpl implements ClassificationQuery {
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }
} }

View File

@ -209,7 +209,7 @@ public class TaskServiceImpl implements TaskService {
@Override @Override
public BulkOperationResults<String, TaskanaException> completeTasks(List<String> taskIds) public BulkOperationResults<String, TaskanaException> completeTasks(List<String> taskIds)
throws InvalidArgumentException, NotAuthorizedException { throws InvalidArgumentException {
try { try {
LOGGER.debug("entry to completeTasks(taskIds = {})", taskIds); LOGGER.debug("entry to completeTasks(taskIds = {})", taskIds);
taskanaEngineImpl.openConnection(); taskanaEngineImpl.openConnection();

View File

@ -136,7 +136,7 @@ public interface QueryMapper {
+ "<if test='type != null'>AND TYPE IN(<foreach item='item' collection='type' separator=',' >#{item}</foreach>)</if> " + "<if test='type != null'>AND TYPE IN(<foreach item='item' collection='type' separator=',' >#{item}</foreach>)</if> "
+ "<if test='domain != null'>AND DOMAIN IN(<foreach item='item' collection='domain' separator=',' >#{item}</foreach>)</if> " + "<if test='domain != null'>AND DOMAIN IN(<foreach item='item' collection='domain' separator=',' >#{item}</foreach>)</if> "
+ "<if test='validInDomain != null'>AND VALID_IN_DOMAIN = #{validInDomain}</if> " + "<if test='validInDomain != null'>AND VALID_IN_DOMAIN = #{validInDomain}</if> "
+ "<if test='created != null'>AND CREATED IN(<foreach item='item' collection='created' separator=',' >SUBSTRING(#{item}, 1, 10)</foreach>)</if> " + "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=' OR ' > ( <if test='item.begin!=null'> CREATED &gt;= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> CREATED &lt;=#{item.end} </if>)</foreach>)</if> "
+ "<if test='nameIn != null'>AND NAME IN(<foreach item='item' collection='nameIn' separator=',' >#{item}</foreach>)</if> " + "<if test='nameIn != null'>AND NAME IN(<foreach item='item' collection='nameIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='nameLike != null'>AND (<foreach item='item' collection='nameLike' separator=' OR '>NAME LIKE #{item}</foreach>)</if> " + "<if test='nameLike != null'>AND (<foreach item='item' collection='nameLike' separator=' OR '>NAME LIKE #{item}</foreach>)</if> "
+ "<if test='descriptionLike != null'>AND DESCRIPTION like #{descriptionLike}</if> " + "<if test='descriptionLike != null'>AND DESCRIPTION like #{descriptionLike}</if> "
@ -351,7 +351,7 @@ public interface QueryMapper {
+ "<if test='type != null'>AND TYPE IN(<foreach item='item' collection='type' separator=',' >#{item}</foreach>)</if> " + "<if test='type != null'>AND TYPE IN(<foreach item='item' collection='type' separator=',' >#{item}</foreach>)</if> "
+ "<if test='domain != null'>AND DOMAIN IN(<foreach item='item' collection='domain' separator=',' >#{item}</foreach>)</if> " + "<if test='domain != null'>AND DOMAIN IN(<foreach item='item' collection='domain' separator=',' >#{item}</foreach>)</if> "
+ "<if test='validInDomain != null'>AND VALID_IN_DOMAIN = #{validInDomain}</if> " + "<if test='validInDomain != null'>AND VALID_IN_DOMAIN = #{validInDomain}</if> "
+ "<if test='created != null'>AND CREATED IN(<foreach item='item' collection='created' separator=',' >SUBSTRING(#{item}, 1, 10)</foreach>)</if> " + "<if test='createdIn !=null'> AND ( <foreach item='item' collection='createdIn' separator=' OR ' > ( <if test='item.begin!=null'> CREATED &gt;= #{item.begin} </if> <if test='item.begin!=null and item.end!=null'> AND </if><if test='item.end!=null'> CREATED &lt;=#{item.end} </if>)</foreach>)</if> "
+ "<if test='nameIn != null'>AND NAME IN(<foreach item='item' collection='nameIn' separator=',' >#{item}</foreach>)</if> " + "<if test='nameIn != null'>AND NAME IN(<foreach item='item' collection='nameIn' separator=',' >#{item}</foreach>)</if> "
+ "<if test='nameLike != null'>AND (<foreach item='item' collection='nameLike' separator=' OR '>NAME LIKE #{item}</foreach>)</if> " + "<if test='nameLike != null'>AND (<foreach item='item' collection='nameLike' separator=' OR '>NAME LIKE #{item}</foreach>)</if> "
+ "<if test='descriptionLike != null'>AND DESCRIPTION like #{descriptionLike}</if> " + "<if test='descriptionLike != null'>AND DESCRIPTION like #{descriptionLike}</if> "

View File

@ -81,7 +81,7 @@ CREATE TABLE CLASSIFICATION(
TYPE VARCHAR(32), TYPE VARCHAR(32),
DOMAIN VARCHAR(255) NOT NULL, DOMAIN VARCHAR(255) NOT NULL,
VALID_IN_DOMAIN BOOLEAN NOT NULL, VALID_IN_DOMAIN BOOLEAN NOT NULL,
CREATED DATE NULL, CREATED TIMESTAMP NULL,
NAME VARCHAR(255) NULL, NAME VARCHAR(255) NULL,
DESCRIPTION VARCHAR(255) NULL, DESCRIPTION VARCHAR(255) NULL,
PRIORITY INT NULL, PRIORITY INT NULL,

View File

@ -1,11 +1,11 @@
package pro.taskana.impl; package pro.taskana.impl;
import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import pro.taskana.ClassificationQuery; import pro.taskana.ClassificationQuery;
import pro.taskana.ClassificationSummary; import pro.taskana.ClassificationSummary;
import pro.taskana.TimeInterval;
/** /**
* Created by BV on 26.10.2017. * Created by BV on 26.10.2017.
@ -52,7 +52,7 @@ public class TestClassificationQuery implements ClassificationQuery {
} }
@Override @Override
public ClassificationQuery created(Instant... created) { public ClassificationQuery createdWithin(TimeInterval... created) {
return this; return this;
} }

View File

@ -9,6 +9,10 @@ import static org.junit.Assert.fail;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.List; import java.util.List;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
@ -26,6 +30,7 @@ import pro.taskana.ClassificationService;
import pro.taskana.ClassificationSummary; import pro.taskana.ClassificationSummary;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode; import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.TimeInterval;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.ClassificationAlreadyExistException; import pro.taskana.exceptions.ClassificationAlreadyExistException;
import pro.taskana.exceptions.ClassificationNotFoundException; import pro.taskana.exceptions.ClassificationNotFoundException;
@ -183,11 +188,10 @@ public class ClassificationServiceImplIntAutoCommitTest {
InvalidArgumentException { InvalidArgumentException {
Classification classification = this.createDummyClassificationWithUniqueKey("", "type1"); Classification classification = this.createDummyClassificationWithUniqueKey("", "type1");
classification = classificationService.createClassification(classification); classification = classificationService.createClassification(classification);
Instant today = Instant.now();
List<ClassificationSummary> list = classificationService.createClassificationQuery() List<ClassificationSummary> list = classificationService.createClassificationQuery()
.validInDomain(Boolean.TRUE) .validInDomain(Boolean.TRUE)
.created(today) .createdWithin(today())
.list(); .list();
Assert.assertEquals(1, list.size()); Assert.assertEquals(1, list.size());
@ -269,7 +273,10 @@ public class ClassificationServiceImplIntAutoCommitTest {
Assert.assertEquals(1, list.size()); Assert.assertEquals(1, list.size());
list = classificationService.createClassificationQuery().custom1In("custom2").list(); list = classificationService.createClassificationQuery().custom1In("custom2").list();
Assert.assertEquals(1, list.size()); Assert.assertEquals(1, list.size());
list = classificationService.createClassificationQuery().descriptionLike("DESC1").categoryIn("category1").list(); list = classificationService.createClassificationQuery()
.descriptionLike("DESC1")
.categoryIn("category1")
.list();
Assert.assertEquals(2, list.size()); Assert.assertEquals(2, list.size());
} }
@ -375,7 +382,7 @@ public class ClassificationServiceImplIntAutoCommitTest {
list = classificationService.createClassificationQuery().validInDomain(true).list(); list = classificationService.createClassificationQuery().validInDomain(true).list();
Assert.assertEquals(listAll.size(), list.size()); Assert.assertEquals(listAll.size(), list.size());
list = classificationService.createClassificationQuery().created(Instant.now()).list(); list = classificationService.createClassificationQuery().createdWithin(today()).list();
Assert.assertEquals(listAll.size(), list.size()); Assert.assertEquals(listAll.size(), list.size());
list = classificationService.createClassificationQuery().domainIn("domain1").validInDomain(false).list(); list = classificationService.createClassificationQuery().domainIn("domain1").validInDomain(false).list();
@ -391,6 +398,12 @@ public class ClassificationServiceImplIntAutoCommitTest {
FileUtils.deleteRecursive("~/data", true); FileUtils.deleteRecursive("~/data", true);
} }
private TimeInterval today() {
Instant begin = LocalDateTime.of(LocalDate.now(), LocalTime.MIN).atZone(ZoneId.systemDefault()).toInstant();
Instant end = LocalDateTime.of(LocalDate.now(), LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant();
return new TimeInterval(begin, end);
}
private Classification createDummyClassificationWithUniqueKey(String domain, String type) { private Classification createDummyClassificationWithUniqueKey(String domain, String type) {
Classification classification = classificationService.newClassification(domain, "TEST" + counter, type); Classification classification = classificationService.newClassification(domain, "TEST" + counter, type);
counter++; counter++;

View File

@ -10,6 +10,10 @@ import java.io.FileNotFoundException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.Instant; import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.List; import java.util.List;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
@ -28,6 +32,7 @@ import pro.taskana.ClassificationService;
import pro.taskana.ClassificationSummary; import pro.taskana.ClassificationSummary;
import pro.taskana.TaskanaEngine; import pro.taskana.TaskanaEngine;
import pro.taskana.TaskanaEngine.ConnectionManagementMode; import pro.taskana.TaskanaEngine.ConnectionManagementMode;
import pro.taskana.TimeInterval;
import pro.taskana.configuration.TaskanaEngineConfiguration; import pro.taskana.configuration.TaskanaEngineConfiguration;
import pro.taskana.exceptions.ClassificationAlreadyExistException; import pro.taskana.exceptions.ClassificationAlreadyExistException;
import pro.taskana.exceptions.ClassificationNotFoundException; import pro.taskana.exceptions.ClassificationNotFoundException;
@ -204,10 +209,9 @@ public class ClassificationServiceImplIntExplicitTest {
taskanaEngineImpl.setConnection(connection); taskanaEngineImpl.setConnection(connection);
Classification classification = this.createNewClassificationWithUniqueKey("", "t1"); Classification classification = this.createNewClassificationWithUniqueKey("", "t1");
classificationService.createClassification(classification); classificationService.createClassification(classification);
Instant today = Instant.now();
List<ClassificationSummary> list = classificationService.createClassificationQuery() List<ClassificationSummary> list = classificationService.createClassificationQuery()
.validInDomain(Boolean.TRUE) .validInDomain(Boolean.TRUE)
.created(today) .createdWithin(today())
.list(); .list();
Assert.assertEquals(1, list.size()); Assert.assertEquals(1, list.size());
} }
@ -301,7 +305,10 @@ public class ClassificationServiceImplIntExplicitTest {
Assert.assertEquals(1, list.size()); Assert.assertEquals(1, list.size());
list = classificationService.createClassificationQuery().custom1In("custom2").list(); list = classificationService.createClassificationQuery().custom1In("custom2").list();
Assert.assertEquals(1, list.size()); Assert.assertEquals(1, list.size());
list = classificationService.createClassificationQuery().descriptionLike("DESC1").categoryIn("category1").list(); list = classificationService.createClassificationQuery()
.descriptionLike("DESC1")
.categoryIn("category1")
.list();
Assert.assertEquals(2, list.size()); Assert.assertEquals(2, list.size());
connection.commit(); connection.commit();
} }
@ -409,7 +416,7 @@ public class ClassificationServiceImplIntExplicitTest {
list = classificationService.createClassificationQuery().validInDomain(true).list(); list = classificationService.createClassificationQuery().validInDomain(true).list();
Assert.assertEquals(2, list.size()); Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().created(Instant.now()).list(); list = classificationService.createClassificationQuery().createdWithin(today()).list();
Assert.assertEquals(2, list.size()); Assert.assertEquals(2, list.size());
list = classificationService.createClassificationQuery().domainIn("domain1").validInDomain(false).list(); list = classificationService.createClassificationQuery().domainIn("domain1").validInDomain(false).list();
Assert.assertEquals(0, list.size()); Assert.assertEquals(0, list.size());
@ -441,4 +448,11 @@ public class ClassificationServiceImplIntExplicitTest {
counter++; counter++;
return classification; return classification;
} }
private TimeInterval today() {
Instant begin = LocalDateTime.of(LocalDate.now(), LocalTime.MIN).atZone(ZoneId.systemDefault()).toInstant();
Instant end = LocalDateTime.of(LocalDate.now(), LocalTime.MAX).atZone(ZoneId.systemDefault()).toInstant();
return new TimeInterval(begin, end);
}
} }