use of org.activiti.api.task.model.impl.TaskCandidateUserImpl in project activiti-cloud by Activiti.
the class AuditServiceIT method getTestUserCandidatesEvents.
private List<CloudRuntimeEvent> getTestUserCandidatesEvents() {
List<CloudRuntimeEvent> testEvents = new ArrayList<>();
TaskCandidateUserImpl taskCandidateUser = new TaskCandidateUserImpl("userId", "1234-abc-5678-def");
CloudTaskCandidateUserAddedEventImpl candidateUserAddedEvent = new CloudTaskCandidateUserAddedEventImpl("TaskCandidateUserAddedEventId", System.currentTimeMillis(), taskCandidateUser);
testEvents.add(candidateUserAddedEvent);
taskCandidateUser = new TaskCandidateUserImpl("userId", "1234-abc-5678-def");
CloudTaskCandidateUserRemovedEventImpl candidateUserRemovedEvent = new CloudTaskCandidateUserRemovedEventImpl("TaskCandidateUserRemovedEventId", System.currentTimeMillis(), taskCandidateUser);
testEvents.add(candidateUserRemovedEvent);
return testEvents;
}
use of org.activiti.api.task.model.impl.TaskCandidateUserImpl in project activiti-cloud by Activiti.
the class TaskCandidatesJpaJsonConverterTest method convertToDatabaseColumnShouldReturnTheEntityJsonRepresentation.
@Test
public void convertToDatabaseColumnShouldReturnTheEntityJsonRepresentation() throws Exception {
// given
TaskCandidateUserImpl candidateUser = new TaskCandidateUserImpl("user-id", "task-id");
// when
String jsonRepresentation = converterCandidateUser.convertToDatabaseColumn(candidateUser);
// then
assertThatJson(jsonRepresentation).node("userId").isEqualTo("user-id").node("taskId").isEqualTo("task-id");
// given
TaskCandidateGroupImpl candidateGroup = new TaskCandidateGroupImpl("group-id", "task-id");
// when
jsonRepresentation = converterCandidateGroup.convertToDatabaseColumn(candidateGroup);
// then
assertThatJson(jsonRepresentation).node("groupId").isEqualTo("group-id").node("taskId").isEqualTo("task-id");
}
use of org.activiti.api.task.model.impl.TaskCandidateUserImpl in project activiti-cloud by Activiti.
the class TaskEntityCandidateUserAddedEventHandlerTest method handleShouldStoreNewTaskCandidateUser.
@Test
public void handleShouldStoreNewTaskCandidateUser() {
// given
TaskCandidateUserImpl candidateUser = new TaskCandidateUserImpl(UUID.randomUUID().toString(), UUID.randomUUID().toString());
CloudTaskCandidateUserAddedEventImpl event = new CloudTaskCandidateUserAddedEventImpl(candidateUser);
// when
handler.handle(event);
// then
ArgumentCaptor<TaskCandidateUser> captor = ArgumentCaptor.forClass(TaskCandidateUser.class);
verify(taskCandidateRepository).save(captor.capture());
assertThat(captor.getValue().getTaskId()).isEqualTo(event.getEntity().getTaskId());
assertThat(captor.getValue().getUserId()).isEqualTo(event.getEntity().getUserId());
}
use of org.activiti.api.task.model.impl.TaskCandidateUserImpl in project activiti-cloud by Activiti.
the class TaskEventContainedBuilder method aTaskWithUserCandidate.
public Task aTaskWithUserCandidate(String taskName, String username, ProcessInstance processInstance) {
TaskImpl task = buildTask(taskName, Task.TaskStatus.CREATED, processInstance);
eventsAggregator.addEvents(new CloudTaskCreatedEventImpl(task), new CloudTaskCandidateUserAddedEventImpl(new TaskCandidateUserImpl(username, task.getId())));
return task;
}
use of org.activiti.api.task.model.impl.TaskCandidateUserImpl in project activiti-cloud by Activiti.
the class QueryTasksIT method shouldGetAddRemoveTaskUserCandidates.
@Test
public void shouldGetAddRemoveTaskUserCandidates() {
// given
Task createdTask = taskEventContainedBuilder.aTaskWithUserCandidate("task with user candidate", "testuser", runningProcessInstance);
eventsAggregator.sendAll();
keycloakTokenProducer.setKeycloakTestUser("testuser");
// when
ResponseEntity<List<String>> responseEntity = getCandidateUsers(createdTask.getId());
// then
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseEntity.getBody()).isNotNull();
assertThat(responseEntity.getBody().size()).isEqualTo(1);
assertThat(responseEntity.getBody().get(0)).isEqualTo("testuser");
// Check adding user candidate
// when
TaskCandidateUserImpl addCandidateUser = new TaskCandidateUserImpl("hruser", createdTask.getId());
producer.send(new CloudTaskCandidateUserAddedEventImpl(addCandidateUser));
// then
responseEntity = getCandidateUsers(createdTask.getId());
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseEntity.getBody()).isNotNull();
assertThat(responseEntity.getBody().size()).isEqualTo(2);
assertThat(responseEntity.getBody().get(0)).isIn("hruser", "testuser");
assertThat(responseEntity.getBody().get(1)).isIn("hruser", "testuser");
// Check deleting user candidate
// when
TaskCandidateUserImpl deleteCandidateUser = new TaskCandidateUserImpl("hruser", createdTask.getId());
producer.send(new CloudTaskCandidateUserRemovedEventImpl(deleteCandidateUser));
// then
responseEntity = getCandidateUsers(createdTask.getId());
assertThat(responseEntity).isNotNull();
assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
assertThat(responseEntity.getBody()).isNotNull();
assertThat(responseEntity.getBody().size()).isEqualTo(1);
assertThat(responseEntity.getBody().get(0)).isEqualTo("testuser");
}
Aggregations