Search in sources :

Example 6 with UserAssignment

use of ch.aaap.harvestclient.domain.UserAssignment in project harvest-client by 3AP-AG.

the class UserAssignmentsApiImpl method create.

@Override
public UserAssignment create(Reference<Project> projectReference, UserAssignment creationInfo) {
    Call<UserAssignment> call = service.create(projectReference.getId(), creationInfo);
    UserAssignment userAssignment = ExceptionHandler.callOrThrow(call);
    log.debug("Created {}", userAssignment);
    return userAssignment;
}
Also used : UserAssignment(ch.aaap.harvestclient.domain.UserAssignment)

Example 7 with UserAssignment

use of ch.aaap.harvestclient.domain.UserAssignment in project harvest-client by 3AP-AG.

the class UserAssignmentsApiImpl method get.

@Override
public UserAssignment get(Reference<Project> projectReference, Reference<UserAssignment> userAssignmentReference) {
    Call<UserAssignment> call = service.get(projectReference.getId(), userAssignmentReference.getId());
    UserAssignment userAssignment = ExceptionHandler.callOrThrow(call);
    log.debug("Gotten {}", userAssignment);
    return userAssignment;
}
Also used : UserAssignment(ch.aaap.harvestclient.domain.UserAssignment)

Example 8 with UserAssignment

use of ch.aaap.harvestclient.domain.UserAssignment in project harvest-client by 3AP-AG.

the class UserAssignmentsApiCreateTest method createDefault.

@Test
void createDefault() {
    UserAssignment creationInfo = ImmutableUserAssignment.builder().user(userReference).build();
    userAssignment = userAssignmentApi.create(projectReference, creationInfo);
    assertThat(userAssignment).isNotNull();
    assertThat(userAssignment.getUser().getId()).isEqualTo(userReference.getId());
    UserAssignment gotten = userAssignmentApi.get(projectReference, this.userAssignment);
    assertThat(gotten).isEqualTo(userAssignment);
}
Also used : ImmutableUserAssignment(ch.aaap.harvestclient.domain.ImmutableUserAssignment) UserAssignment(ch.aaap.harvestclient.domain.UserAssignment) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 9 with UserAssignment

use of ch.aaap.harvestclient.domain.UserAssignment 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);
}
Also used : ImmutableUserAssignment(ch.aaap.harvestclient.domain.ImmutableUserAssignment) UserAssignment(ch.aaap.harvestclient.domain.UserAssignment) UserAssignmentFilter(ch.aaap.harvestclient.api.filter.UserAssignmentFilter) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 10 with UserAssignment

use of ch.aaap.harvestclient.domain.UserAssignment 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);
}
Also used : ImmutableUserAssignment(ch.aaap.harvestclient.domain.ImmutableUserAssignment) UserAssignment(ch.aaap.harvestclient.domain.UserAssignment) UserAssignmentFilter(ch.aaap.harvestclient.api.filter.UserAssignmentFilter) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Aggregations

UserAssignment (ch.aaap.harvestclient.domain.UserAssignment)12 HarvestTest (ch.aaap.harvestclient.HarvestTest)9 ImmutableUserAssignment (ch.aaap.harvestclient.domain.ImmutableUserAssignment)9 Test (org.junit.jupiter.api.Test)9 UserAssignmentFilter (ch.aaap.harvestclient.api.filter.UserAssignmentFilter)4 ImmutableUserAssignmentUpdateInfo (ch.aaap.harvestclient.domain.param.ImmutableUserAssignmentUpdateInfo)3 UserAssignmentUpdateInfo (ch.aaap.harvestclient.domain.param.UserAssignmentUpdateInfo)3 User (ch.aaap.harvestclient.domain.User)2 UserAssignmentsApi (ch.aaap.harvestclient.api.UserAssignmentsApi)1 Harvest (ch.aaap.harvestclient.core.Harvest)1 Project (ch.aaap.harvestclient.domain.Project)1 Reference (ch.aaap.harvestclient.domain.reference.Reference)1 Instant (java.time.Instant)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 AfterEach (org.junit.jupiter.api.AfterEach)1 ExistingData (util.ExistingData)1 TestSetupUtil (util.TestSetupUtil)1