use of ch.aaap.harvestclient.domain.Project in project harvest-client by 3AP-AG.
the class ProjectsApiUpdateTest method beforeEach.
@BeforeEach
void beforeEach(TestInfo testInfo) {
Reference<Client> clientReference = ExistingData.getInstance().getClientReference();
String name = "Project for test " + testInfo.getDisplayName();
boolean billable = true;
Project.BillingMethod billBy = Project.BillingMethod.PROJECT;
Project.BudgetMethod budgetBy = Project.BudgetMethod.HOURS_PER_TASK;
Project creationInfo = ImmutableProject.builder().client(clientReference).name(name).billable(billable).billBy(billBy).budgetBy(budgetBy).build();
project = projectsApi.create(creationInfo);
}
use of ch.aaap.harvestclient.domain.Project 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.domain.Project in project harvest-client by 3AP-AG.
the class ProjectsApiCreateTest method createAllOptions.
@Test
void createAllOptions(TestInfo testInfo) {
Reference<Client> clientReference = ExistingData.getInstance().getClientReference();
String name = "Project for test " + testInfo.getDisplayName();
boolean billable = true;
Project.BillingMethod billBy = Project.BillingMethod.PROJECT;
Project.BudgetMethod budgetBy = Project.BudgetMethod.HOURS_PER_PROJECT;
String code = "testCode";
boolean active = false;
// see other test for fixedFee = true
boolean fixedFee = false;
double hourlyRate = 240;
double budget = 120;
boolean notifyWhenOverBudget = true;
double overBudgetNotificationPercentage = 90.;
boolean showBudgetToAll = true;
double costBudget = 2000;
double fee = 5000;
String notes = "test notes";
LocalDate start = LocalDate.now();
LocalDate end = start.plusMonths(3).plusDays(2);
Project creationInfo = ImmutableProject.builder().client(clientReference).name(name).billable(billable).billBy(billBy).budgetBy(budgetBy).code(code).active(active).fixedFee(fixedFee).hourlyRate(hourlyRate).budget(budget).notifyWhenOverBudget(notifyWhenOverBudget).overBudgetNotificationPercentage(overBudgetNotificationPercentage).showBudgetToAll(showBudgetToAll).costBudget(costBudget).costBudgetIncludeExpenses(false).fee(fee).notes(notes).startsOn(start).endsOn(end).build();
project = projectsApi.create(creationInfo);
assertThat(project).isEqualToIgnoringGivenFields(creationInfo, "clientId", "id", "createdAt", "updatedAt", "client", "fee");
// fee can only be set by having fixed_fee = true
assertThat(project.getFee()).isNull();
assertThat(project.getClient().getId()).isEqualTo(clientReference.getId());
assertThat(project.getCreatedAt()).isCloseTo(Instant.now(), within(1, ChronoUnit.MINUTES));
assertThat(project.getUpdatedAt()).isCloseTo(Instant.now(), within(1, ChronoUnit.MINUTES));
// get test
Project gottenProject = projectsApi.get(project);
assertThat(gottenProject).isEqualToComparingFieldByField(project);
}
use of ch.aaap.harvestclient.domain.Project in project harvest-client by 3AP-AG.
the class ProjectsApiCreateTest method createTotalProjectFees.
@Test
void createTotalProjectFees(TestInfo testInfo) {
Reference<Client> clientReference = ExistingData.getInstance().getClientReference();
String name = "Project for test " + testInfo.getDisplayName();
boolean billable = true;
Project.BillingMethod billBy = Project.BillingMethod.PROJECT;
Project.BudgetMethod budgetBy = Project.BudgetMethod.TOTAL_PROJECT_FEES;
String code = "testCode";
boolean active = false;
// see other test for fixedFee = true
boolean fixedFee = false;
double hourlyRate = 240;
double budget = 120;
boolean notifyWhenOverBudget = true;
double overBudgetNotificationPercentage = 90.;
boolean showBudgetToAll = true;
double costBudget = 2000;
boolean costBudgetIncludeExpenses = true;
double fee = 5000;
String notes = "test notes";
LocalDate start = LocalDate.now();
LocalDate end = start.plusMonths(3).plusDays(2);
Project creationInfo = ImmutableProject.builder().client(clientReference).name(name).billable(billable).billBy(billBy).budgetBy(budgetBy).code(code).active(active).fixedFee(fixedFee).hourlyRate(hourlyRate).budget(budget).notifyWhenOverBudget(notifyWhenOverBudget).overBudgetNotificationPercentage(overBudgetNotificationPercentage).showBudgetToAll(showBudgetToAll).costBudget(costBudget).costBudgetIncludeExpenses(costBudgetIncludeExpenses).fee(fee).notes(notes).startsOn(start).endsOn(end).build();
project = projectsApi.create(creationInfo);
assertThat(project).isEqualToIgnoringGivenFields(creationInfo, "clientId", "id", "createdAt", "updatedAt", "client", "fee");
// fee can only be set by having fixed_fee = true
assertThat(project.getFee()).isNull();
assertThat(project.getClient().getId()).isEqualTo(clientReference.getId());
assertThat(project.getCreatedAt()).isCloseTo(Instant.now(), within(1, ChronoUnit.MINUTES));
assertThat(project.getUpdatedAt()).isCloseTo(Instant.now(), within(1, ChronoUnit.MINUTES));
// get test
Project gottenProject = projectsApi.get(project);
assertThat(gottenProject).isEqualToComparingFieldByField(project);
}
use of ch.aaap.harvestclient.domain.Project in project harvest-client by 3AP-AG.
the class ProjectsApiCreateTest method createFixedFee.
@Test
void createFixedFee(TestInfo testInfo) {
Reference<Client> clientReference = ExistingData.getInstance().getClientReference();
String name = "Project for test " + testInfo.getDisplayName();
boolean billable = true;
Project.BillingMethod billBy = Project.BillingMethod.TASKS;
Project.BudgetMethod budgetBy = Project.BudgetMethod.TOTAL_PROJECT_FEES;
String code = "testCode";
boolean active = false;
boolean fixedFee = true;
double hourlyRate = 240;
double budget = 120;
boolean notifyWhenOverBudget = true;
double overBudgetNotificationPercentage = 90.;
boolean showBudgetToAll = true;
double costBudget = 2000;
boolean costBudgetIncludeExpenses = true;
double fee = 5000;
String notes = "test notes";
LocalDate start = LocalDate.now();
LocalDate end = start.plusMonths(3).plusDays(2);
Project creationInfo = ImmutableProject.builder().client(clientReference).name(name).billable(billable).billBy(billBy).budgetBy(budgetBy).code(code).active(active).fixedFee(fixedFee).hourlyRate(hourlyRate).budget(budget).notifyWhenOverBudget(notifyWhenOverBudget).overBudgetNotificationPercentage(overBudgetNotificationPercentage).showBudgetToAll(showBudgetToAll).costBudget(costBudget).costBudgetIncludeExpenses(costBudgetIncludeExpenses).fee(fee).notes(notes).startsOn(start).endsOn(end).build();
project = projectsApi.create(creationInfo);
assertThat(project).isEqualToIgnoringGivenFields(creationInfo, "clientId", "client", "id", "createdAt", "updatedAt", "costBudget");
// setting cost budget is ignored, fee takes its place
assertThat(project.getCostBudget()).isEqualTo(fee);
assertThat(project.getClient().getId()).isEqualTo(clientReference.getId());
}
Aggregations