Fix intermittent test failures
Some tests in ScenarioModelTest failed due to creating several orders with the same name. This shouldn't be a problem since each creation is rolled back, but somehow there was already an order with that name or sometimes the creations are not rolled back. FEA: ItEr75S04BugFixing
This commit is contained in:
parent
a5d28c39fd
commit
1a335dbab3
1 changed files with 7 additions and 2 deletions
|
|
@ -32,6 +32,7 @@ import static org.navalplanner.web.test.WebappGlobalNames.WEBAPP_SPRING_CONFIG_T
|
|||
import static org.navalplanner.web.test.WebappGlobalNames.WEBAPP_SPRING_SECURITY_CONFIG_TEST_FILE;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
@ -126,7 +127,7 @@ public class ScenarioModelTest {
|
|||
SessionFactory sessionFactory) {
|
||||
Order order = Order.create();
|
||||
order.setCode(UUID.randomUUID().toString());
|
||||
order.setName("order-name");
|
||||
order.setName(randomize("order-name"));
|
||||
order.setInitDate(new Date());
|
||||
order.setCalendar(configurationDAO.getConfiguration()
|
||||
.getDefaultCalendar());
|
||||
|
|
@ -138,7 +139,7 @@ public class ScenarioModelTest {
|
|||
.createOrderLineWithUnfixedPercentage(1000);
|
||||
order.add(orderLine);
|
||||
orderLine.setCode(UUID.randomUUID().toString());
|
||||
orderLine.setName("order-line-name");
|
||||
orderLine.setName(randomize("order-line-name"));
|
||||
orderDAO.save(order);
|
||||
orderDAO.flush();
|
||||
sessionFactory.getCurrentSession().evict(order);
|
||||
|
|
@ -147,6 +148,10 @@ public class ScenarioModelTest {
|
|||
return order;
|
||||
}
|
||||
|
||||
private static String randomize(String name) {
|
||||
return name + new Random().nextInt();
|
||||
}
|
||||
|
||||
private Order givenStoredOrderInScenario(Scenario scenario) {
|
||||
return givenStoredOrderInScenario(scenario, configurationDAO, orderDAO,
|
||||
sessionFactory);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue