use of ch.aaap.harvestclient.api.filter.UserAssignmentFilter in project harvest-client by 3AP-AG.
the class UserAssignmentsApiListTest method listByUpdatedSince.
@Test
void listByUpdatedSince() {
Instant creationTime = Instant.now().minusSeconds(1);
UserAssignment creationInfo = ImmutableUserAssignment.builder().user(userReference).build();
userAssignment = userAssignmentApi.create(projectReference, creationInfo);
log.debug("time now: {}", Instant.now());
log.debug("Creation time for userAssignment: {}", userAssignment.getCreatedAt());
log.debug("Update time for userAssignment: {}", userAssignment.getUpdatedAt());
UserAssignmentFilter filter = new UserAssignmentFilter();
filter.setUpdatedSince(creationTime);
List<UserAssignment> userAssignments = userAssignmentApi.list(projectReference, filter);
assertThat(userAssignments).usingFieldByFieldElementComparator().containsExactly(userAssignment);
}
use of ch.aaap.harvestclient.api.filter.UserAssignmentFilter in project harvest-client by 3AP-AG.
the class UserAssignmentsApiListTest method list.
@Test
void list() {
UserAssignmentFilter filter = new UserAssignmentFilter();
List<UserAssignment> userAssignments = userAssignmentApi.list(projectReference, filter);
assertThat(userAssignments).isNotEmpty();
}
use of ch.aaap.harvestclient.api.filter.UserAssignmentFilter in project harvest-client by 3AP-AG.
the class ProjectAssignmentsApiImplTest method listSelf.
@Test
void listSelf(TestInfo testInfo) {
Project project = null;
try {
final Project tempProject = harvest.projects().create(ImmutableProject.builder().name("Project for " + testInfo.getDisplayName()).billBy(Project.BillingMethod.PROJECT).budgetBy(Project.BudgetMethod.HOURS_PER_PROJECT).billable(false).client(ExistingData.getInstance().getClientReference()).build());
project = tempProject;
User self = harvest.users().getSelf();
// remove self from tempProject
harvest.userAssignments().list(project, new UserAssignmentFilter()).stream().filter(ua -> ua.getUser().getId().equals(self.getId())).forEach(ua -> harvest.userAssignments().delete(tempProject, ua));
List<ProjectAssignment> projectAssignments = projectAssignmentsApi.listSelf();
assertThat(projectAssignments).isNotEmpty();
assertThat(projectAssignments).extracting("project").extracting("id").doesNotContain(tempProject.getId());
} finally {
if (project != null) {
harvest.projects().delete(project);
}
}
}
use of ch.aaap.harvestclient.api.filter.UserAssignmentFilter in project harvest-client by 3AP-AG.
the class UserAssignmentsApiListTest method listByActive.
@Test
void listByActive() {
UserAssignment creationInfo = ImmutableUserAssignment.builder().user(userReference).active(true).build();
userAssignment = userAssignmentApi.create(projectReference, creationInfo);
UserAssignmentFilter filter = new UserAssignmentFilter();
filter.setActive(true);
List<UserAssignment> userAssignments = userAssignmentApi.list(projectReference, filter);
assertThat(userAssignments).usingFieldByFieldElementComparator().contains(userAssignment);
}
use of ch.aaap.harvestclient.api.filter.UserAssignmentFilter in project harvest-client by 3AP-AG.
the class UserAssignmentsApiListTest method listPaginated.
@Test
void listPaginated() {
// create a second one to check the pagination
UserAssignment creationInfo = ImmutableUserAssignment.builder().user(userReference).active(true).build();
userAssignment = userAssignmentApi.create(projectReference, creationInfo);
Pagination<UserAssignment> pagination = userAssignmentApi.list(projectReference, new UserAssignmentFilter(), 1, 1);
List<UserAssignment> result = pagination.getList();
assertThat(result).hasSize(1);
assertThat(pagination.getTotalPages()).isGreaterThanOrEqualTo(2);
assertThat(pagination.getNextPage()).isEqualTo(2);
assertThat(pagination.getPreviousPage()).isNull();
assertThat(pagination.getPerPage()).isEqualTo(1);
assertThat(pagination.getTotalPages()).isGreaterThanOrEqualTo(2);
}
Aggregations