@Test
@Transactional
public void testSetWorkHoursHoursGroupNoFixedAndHoursGroupNoFixedAndHoursGroupFixedPercentageIncreaseValue() {
OrderLine orderLine = OrderLine.create();
HoursGroup hoursGroup = HoursGroup.create(orderLine);
hoursGroup.setWorkingHours(50);
HoursGroup hoursGroup2 = HoursGroup.create(orderLine);
hoursGroup2.setWorkingHours(50);
HoursGroup hoursGroup3 = HoursGroup.create(orderLine);
hoursGroup3.setWorkingHours(100);
orderLine.addHoursGroup(hoursGroup);
orderLine.addHoursGroup(hoursGroup2);
orderLine.addHoursGroup(hoursGroup3);
hoursGroup3.setFixedPercentage(true);
hoursGroup3.setPercentage(new BigDecimal(0.50).setScale(2));
assertThat(orderLine.getWorkHours(), equalTo(200));
try {
orderLine.setWorkHours(300);
} catch (IllegalArgumentException e) {
fail("It should not throw an exception");
}
assertThat(orderLine.getWorkHours(), equalTo(300));
assertThat(orderLine.getHoursGroups().size(), equalTo(3));
assertThat(hoursGroup.getWorkingHours(), equalTo(75));
assertThat(hoursGroup2.getWorkingHours(), equalTo(75));
assertThat(hoursGroup3.getWorkingHours(), equalTo(150));
assertThat(hoursGroup3.getPercentage(), equalTo(new BigDecimal(0.50)
.setScale(2)));
}