TSK-44 implement Holgers comments - assert only Exception type, not message; rename attachment id prefix and helper method
This commit is contained in:
parent
8b26f7564d
commit
a6f95fcd55
|
@ -46,7 +46,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TaskServiceImpl.class);
|
||||
private static final String ID_PREFIX_OBJECT_REFERENCE = "ORI";
|
||||
private static final String ID_PREFIX_ATTACHMENT = "ATT";
|
||||
private static final String ID_PREFIX_ATTACHMENT = "TAI";
|
||||
private static final String ID_PREFIX_TASK = "TKI";
|
||||
private static final String ID_PREFIX_BUSINESS_PROCESS = "BPI";
|
||||
private TaskanaEngine taskanaEngine;
|
||||
|
@ -177,7 +177,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
this.classificationService.getClassification(classification.getKey(),
|
||||
classification.getDomain());
|
||||
|
||||
validatePrimaryObjectReference(task.getPrimaryObjRef(), "Task");
|
||||
validateObjectReference(task.getPrimaryObjRef(), "primary ObjectReference", "Task");
|
||||
validateAttachments(task);
|
||||
standardSettings(task);
|
||||
this.taskMapper.insert(task);
|
||||
|
@ -431,24 +431,24 @@ public class TaskServiceImpl implements TaskService {
|
|||
task.setPrimaryObjRef(objRef);
|
||||
}
|
||||
|
||||
private void validatePrimaryObjectReference(ObjectReference primObjRef, String objName)
|
||||
private void validateObjectReference(ObjectReference objRef, String objRefType, String objName)
|
||||
throws InvalidArgumentException {
|
||||
// check that all values in the primary ObjectReference are set correctly
|
||||
if (primObjRef == null) {
|
||||
throw new InvalidArgumentException("primary ObjectReference of " + objName + " must not be null");
|
||||
} else if (primObjRef.getCompany() == null || primObjRef.getCompany().length() == 0) {
|
||||
// check that all values in the ObjectReference are set correctly
|
||||
if (objRef == null) {
|
||||
throw new InvalidArgumentException(objRefType + " of " + objName + " must not be null");
|
||||
} else if (objRef.getCompany() == null || objRef.getCompany().length() == 0) {
|
||||
throw new InvalidArgumentException(
|
||||
"Company of primary ObjectReference of " + objName + " must not be empty");
|
||||
} else if (primObjRef.getSystem() == null || primObjRef.getSystem().length() == 0) {
|
||||
"Company of " + objRefType + " of " + objName + " must not be empty");
|
||||
} else if (objRef.getSystem() == null || objRef.getSystem().length() == 0) {
|
||||
throw new InvalidArgumentException(
|
||||
"System of primary ObjectReference of " + objName + " must not be empty");
|
||||
} else if (primObjRef.getSystemInstance() == null || primObjRef.getSystemInstance().length() == 0) {
|
||||
"System of " + objRefType + " of " + objName + " must not be empty");
|
||||
} else if (objRef.getSystemInstance() == null || objRef.getSystemInstance().length() == 0) {
|
||||
throw new InvalidArgumentException(
|
||||
"SystemInstance of primary ObjectReference of " + objName + " must not be empty");
|
||||
} else if (primObjRef.getType() == null || primObjRef.getType().length() == 0) {
|
||||
throw new InvalidArgumentException("Type of primary ObjectReference of " + objName + " must not be empty");
|
||||
} else if (primObjRef.getValue() == null || primObjRef.getValue().length() == 0) {
|
||||
throw new InvalidArgumentException("Value of primary ObjectReference of " + objName + " must not be empty");
|
||||
"SystemInstance of " + objRefType + " of " + objName + " must not be empty");
|
||||
} else if (objRef.getType() == null || objRef.getType().length() == 0) {
|
||||
throw new InvalidArgumentException("Type of " + objRefType + " of " + objName + " must not be empty");
|
||||
} else if (objRef.getValue() == null || objRef.getValue().length() == 0) {
|
||||
throw new InvalidArgumentException("Value of" + objRefType + " of " + objName + " must not be empty");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
for (Attachment attachment : attachments) {
|
||||
ObjectReference objRef = attachment.getObjectReference();
|
||||
validatePrimaryObjectReference(objRef, "Attachment");
|
||||
validateObjectReference(objRef, "ObjectReference", "Attachment");
|
||||
if (attachment.getClassification() == null) {
|
||||
throw new InvalidArgumentException("Classification of attachment " + attachment + " must not be null");
|
||||
}
|
||||
|
@ -470,7 +470,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
|
||||
private void standardUpdateActions(TaskImpl oldTaskImpl, TaskImpl newTaskImpl)
|
||||
throws InvalidArgumentException, ConcurrencyException {
|
||||
validatePrimaryObjectReference(newTaskImpl.getPrimaryObjRef(), "Task");
|
||||
validateObjectReference(newTaskImpl.getPrimaryObjRef(), "primary ObjectReference", "Task");
|
||||
if (oldTaskImpl.getModified() != null && !oldTaskImpl.getModified().equals(newTaskImpl.getModified())
|
||||
|| oldTaskImpl.getClaimed() != null && !oldTaskImpl.getClaimed().equals(newTaskImpl.getClaimed())
|
||||
|| oldTaskImpl.getState() != null && !oldTaskImpl.getState().equals(newTaskImpl.getState())) {
|
||||
|
|
|
@ -141,4 +141,4 @@ CREATE TABLE ATTACHMENT(
|
|||
RECEIVED TIMESTAMP NULL,
|
||||
CUSTOM_ATTRIBUTES BLOB NULL,
|
||||
PRIMARY KEY (ID)
|
||||
);
|
||||
);
|
||||
|
|
|
@ -86,8 +86,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
Task createdTask = taskService.createTask(newTask);
|
||||
|
||||
assertNotNull(createdTask);
|
||||
// assertNotNull(createdTask.getAttachments());
|
||||
// assertEquals(1, createdTask.getAttachments().size());
|
||||
assertNotNull(createdTask.getAttachments());
|
||||
assertEquals(1, createdTask.getAttachments().size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
@ -114,9 +114,8 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
Task createdTask = taskService.createTask(newTask);
|
||||
|
||||
assertNotNull(createdTask);
|
||||
// assertNotNull(createdTask.getAttachments());
|
||||
// assertEquals(2, createdTask.getAttachments().size());
|
||||
// further assertions
|
||||
assertNotNull(createdTask.getAttachments());
|
||||
assertEquals(2, createdTask.getAttachments().size());
|
||||
}
|
||||
|
||||
@WithAccessId(
|
||||
|
@ -136,7 +135,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("primary ObjectReference of Attachment must not be null", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
newTask = makeNewTask(taskService);
|
||||
|
@ -146,7 +145,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("Value of primary ObjectReference of Attachment must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
newTask = makeNewTask(taskService);
|
||||
|
@ -157,7 +156,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("Type of primary ObjectReference of Attachment must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
newTask = makeNewTask(taskService);
|
||||
newTask.addAttachment(createAttachment("DOKTYP_DEFAULT",
|
||||
|
@ -167,7 +166,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("SystemInstance of primary ObjectReference of Attachment must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
newTask = makeNewTask(taskService);
|
||||
newTask.addAttachment(createAttachment("DOKTYP_DEFAULT",
|
||||
|
@ -177,7 +176,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("System of primary ObjectReference of Attachment must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
newTask = makeNewTask(taskService);
|
||||
newTask.addAttachment(createAttachment("DOKTYP_DEFAULT",
|
||||
|
@ -187,7 +186,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("Company of primary ObjectReference of Attachment must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -311,7 +310,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("primary ObjectReference of Task must not be null", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// Exception
|
||||
|
@ -323,7 +322,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("Value of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// Exception
|
||||
|
@ -336,7 +335,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("Type of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// Exception
|
||||
|
@ -349,7 +348,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("SystemInstance of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// Exception
|
||||
|
@ -362,7 +361,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("System of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// Exception
|
||||
|
@ -375,7 +374,7 @@ public class CreateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
createdTask = taskService.createTask(newTask);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("Company of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
// Exception
|
||||
|
|
|
@ -74,39 +74,39 @@ public class UpdateTaskAccTest extends AbstractAccTest {
|
|||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("primary ObjectReference of Task must not be null", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", "VNR", null));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("Value of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
|
||||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", "INSTANCE_A", null, "1234567"));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("Type of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", "SYSTEM_A", null, "VNR", "1234567"));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("SystemInstance of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
task.setPrimaryObjRef(createObjectReference("COMPANY_A", null, "INSTANCE_A", "VNR", "1234567"));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("System of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
task.setPrimaryObjRef(createObjectReference(null, "SYSTEM_A", "INSTANCE_A", "VNR", "1234567"));
|
||||
try {
|
||||
updatedTask = taskService.updateTask(task);
|
||||
} catch (InvalidArgumentException ex) {
|
||||
assertEquals("Company of primary ObjectReference of Task must not be empty", ex.getMessage());
|
||||
// nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue