Search in sources :

Example 1 with UserAssignment

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

the class UserAssignmentsApiCreateTest method createAllOptions.

@Test
void createAllOptions() {
    UserAssignment creationInfo = ImmutableUserAssignment.builder().user(userReference).active(false).hourlyRate(220.).budget(1111.).projectManager(true).build();
    userAssignment = userAssignmentApi.create(projectReference, creationInfo);
    assertThat(userAssignment).isNotNull();
    assertThat(userAssignment).usingComparatorForType((x, y) -> (int) (y.getId() - x.getId()), Reference.class).isEqualToIgnoringNullFields(creationInfo);
}
Also used : HarvestTest(ch.aaap.harvestclient.HarvestTest) UserAssignmentsApi(ch.aaap.harvestclient.api.UserAssignmentsApi) ImmutableUserAssignment(ch.aaap.harvestclient.domain.ImmutableUserAssignment) UserAssignment(ch.aaap.harvestclient.domain.UserAssignment) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TestSetupUtil(util.TestSetupUtil) Test(org.junit.jupiter.api.Test) Harvest(ch.aaap.harvestclient.core.Harvest) AfterEach(org.junit.jupiter.api.AfterEach) Reference(ch.aaap.harvestclient.domain.reference.Reference) Project(ch.aaap.harvestclient.domain.Project) User(ch.aaap.harvestclient.domain.User) ExistingData(util.ExistingData) ImmutableUserAssignment(ch.aaap.harvestclient.domain.ImmutableUserAssignment) UserAssignment(ch.aaap.harvestclient.domain.UserAssignment) Reference(ch.aaap.harvestclient.domain.reference.Reference) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 2 with UserAssignment

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

Example 3 with UserAssignment

use of ch.aaap.harvestclient.domain.UserAssignment 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();
}
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 4 with UserAssignment

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

the class UserAssignmentsApiUpdateTest method changeActive.

@Test
void changeActive() {
    userAssignment = userAssignmentApi.create(projectReference, ImmutableUserAssignment.builder().user(userReference).build());
    UserAssignmentUpdateInfo updateInfo = ImmutableUserAssignmentUpdateInfo.builder().active(false).build();
    UserAssignment updatedUserAssignment = userAssignmentApi.update(projectReference, userAssignment, updateInfo);
    assertThat(updatedUserAssignment.getActive()).isEqualTo(updateInfo.getActive());
}
Also used : ImmutableUserAssignment(ch.aaap.harvestclient.domain.ImmutableUserAssignment) UserAssignment(ch.aaap.harvestclient.domain.UserAssignment) UserAssignmentUpdateInfo(ch.aaap.harvestclient.domain.param.UserAssignmentUpdateInfo) ImmutableUserAssignmentUpdateInfo(ch.aaap.harvestclient.domain.param.ImmutableUserAssignmentUpdateInfo) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 5 with UserAssignment

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

the class UserAssignmentsApiImpl method update.

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

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