Search in sources :

Example 1 with ProjectAssignment

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

the class ProjectAssignmentsApiImplTest method listUpdatedSinceNow.

@Test
void listUpdatedSinceNow() {
    Instant updatedSince = Instant.now();
    List<ProjectAssignment> projectAssignments = projectAssignmentsApi.list(userReference, updatedSince);
    // nothing was created just now
    assertThat(projectAssignments).isEmpty();
}
Also used : ProjectAssignment(ch.aaap.harvestclient.domain.ProjectAssignment) Instant(java.time.Instant) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 2 with ProjectAssignment

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

the class ProjectAssignmentsApiImplTest method listUpdatedSinceLongAgo.

@Test
void listUpdatedSinceLongAgo() {
    Instant updatedSince = Instant.ofEpochSecond(0);
    List<ProjectAssignment> projectAssignments = projectAssignmentsApi.list(userReference, updatedSince);
    assertThat(projectAssignments).contains(projectAssignment);
}
Also used : ProjectAssignment(ch.aaap.harvestclient.domain.ProjectAssignment) Instant(java.time.Instant) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Example 3 with ProjectAssignment

use of ch.aaap.harvestclient.domain.ProjectAssignment 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);
        }
    }
}
Also used : HarvestTest(ch.aaap.harvestclient.HarvestTest) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Instant(java.time.Instant) TestInfo(org.junit.jupiter.api.TestInfo) TestSetupUtil(util.TestSetupUtil) Test(org.junit.jupiter.api.Test) Harvest(ch.aaap.harvestclient.core.Harvest) List(java.util.List) Reference(ch.aaap.harvestclient.domain.reference.Reference) ProjectAssignmentsApi(ch.aaap.harvestclient.api.ProjectAssignmentsApi) Project(ch.aaap.harvestclient.domain.Project) ImmutableProject(ch.aaap.harvestclient.domain.ImmutableProject) User(ch.aaap.harvestclient.domain.User) UserAssignmentFilter(ch.aaap.harvestclient.api.filter.UserAssignmentFilter) ProjectAssignment(ch.aaap.harvestclient.domain.ProjectAssignment) ExistingData(util.ExistingData) Project(ch.aaap.harvestclient.domain.Project) ImmutableProject(ch.aaap.harvestclient.domain.ImmutableProject) User(ch.aaap.harvestclient.domain.User) ProjectAssignment(ch.aaap.harvestclient.domain.ProjectAssignment) UserAssignmentFilter(ch.aaap.harvestclient.api.filter.UserAssignmentFilter) HarvestTest(ch.aaap.harvestclient.HarvestTest) Test(org.junit.jupiter.api.Test)

Aggregations

HarvestTest (ch.aaap.harvestclient.HarvestTest)3 ProjectAssignment (ch.aaap.harvestclient.domain.ProjectAssignment)3 Instant (java.time.Instant)3 Test (org.junit.jupiter.api.Test)3 ProjectAssignmentsApi (ch.aaap.harvestclient.api.ProjectAssignmentsApi)1 UserAssignmentFilter (ch.aaap.harvestclient.api.filter.UserAssignmentFilter)1 Harvest (ch.aaap.harvestclient.core.Harvest)1 ImmutableProject (ch.aaap.harvestclient.domain.ImmutableProject)1 Project (ch.aaap.harvestclient.domain.Project)1 User (ch.aaap.harvestclient.domain.User)1 Reference (ch.aaap.harvestclient.domain.reference.Reference)1 List (java.util.List)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 TestInfo (org.junit.jupiter.api.TestInfo)1 ExistingData (util.ExistingData)1 TestSetupUtil (util.TestSetupUtil)1