Search in sources :

Example 1 with TaskCandidateUserImpl

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;
}
Also used : TaskCandidateUserImpl(org.activiti.api.task.model.impl.TaskCandidateUserImpl) ArrayList(java.util.ArrayList) CloudTaskCandidateUserRemovedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserRemovedEventImpl) CloudTaskCandidateUserAddedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserAddedEventImpl) CloudRuntimeEvent(org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent)

Example 2 with TaskCandidateUserImpl

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");
}
Also used : TaskCandidateUserImpl(org.activiti.api.task.model.impl.TaskCandidateUserImpl) TaskCandidateGroupImpl(org.activiti.api.task.model.impl.TaskCandidateGroupImpl) Test(org.junit.jupiter.api.Test)

Example 3 with TaskCandidateUserImpl

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());
}
Also used : TaskCandidateUserImpl(org.activiti.api.task.model.impl.TaskCandidateUserImpl) CloudTaskCandidateUserAddedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserAddedEventImpl) TaskCandidateUser(org.activiti.cloud.services.query.model.TaskCandidateUser) Test(org.junit.jupiter.api.Test)

Example 4 with TaskCandidateUserImpl

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;
}
Also used : TaskImpl(org.activiti.api.task.model.impl.TaskImpl) TaskCandidateUserImpl(org.activiti.api.task.model.impl.TaskCandidateUserImpl)

Example 5 with TaskCandidateUserImpl

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");
}
Also used : Task(org.activiti.api.task.model.Task) CloudTask(org.activiti.cloud.api.task.model.CloudTask) TaskCandidateUserImpl(org.activiti.api.task.model.impl.TaskCandidateUserImpl) CloudTaskCandidateUserRemovedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserRemovedEventImpl) List(java.util.List) CloudTaskCandidateUserAddedEventImpl(org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserAddedEventImpl) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

TaskCandidateUserImpl (org.activiti.api.task.model.impl.TaskCandidateUserImpl)8 Test (org.junit.jupiter.api.Test)5 CloudTaskCandidateUserAddedEventImpl (org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserAddedEventImpl)4 CloudTaskCandidateUserRemovedEventImpl (org.activiti.cloud.api.task.model.impl.events.CloudTaskCandidateUserRemovedEventImpl)3 List (java.util.List)2 Task (org.activiti.api.task.model.Task)2 TaskImpl (org.activiti.api.task.model.impl.TaskImpl)2 CloudTask (org.activiti.cloud.api.task.model.CloudTask)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 TaskCandidateGroup (org.activiti.api.task.model.TaskCandidateGroup)1 TaskCandidateGroupImpl (org.activiti.api.task.model.impl.TaskCandidateGroupImpl)1 CloudRuntimeEvent (org.activiti.cloud.api.model.shared.events.CloudRuntimeEvent)1 CloudTaskAssignedEventImpl (org.activiti.cloud.api.task.model.impl.events.CloudTaskAssignedEventImpl)1 CloudTaskCompletedEventImpl (org.activiti.cloud.api.task.model.impl.events.CloudTaskCompletedEventImpl)1 TaskCandidateUser (org.activiti.cloud.services.query.model.TaskCandidateUser)1