Bug fix on test case. The database could not be empty, so the new number of workers must take into account the previous number.
This commit is contained in:
parent
d6063ba5ba
commit
3865b7c800
1 changed files with 11 additions and 12 deletions
|
|
@ -1,12 +1,5 @@
|
||||||
package org.navalplanner.business.test.resources.services;
|
package org.navalplanner.business.test.resources.services;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.navalplanner.business.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_FILE;
|
|
||||||
import static org.navalplanner.business.test.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_TEST_FILE;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||||
|
|
@ -19,12 +12,17 @@ import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.navalplanner.business.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_FILE;
|
||||||
|
import static org.navalplanner.business.test.BusinessGlobalNames.BUSINESS_SPRING_CONFIG_TEST_FILE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class for testing <code>ResourceService</code>. The service and the
|
* A class for testing <code>ResourceService</code>. The service and the
|
||||||
* resource DAOs are autowired.
|
* resource DAOs are autowired.
|
||||||
*
|
|
||||||
* @author Fernando Bellas Permuy <fbellas@udc.es>
|
* @author Fernando Bellas Permuy <fbellas@udc.es>
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(locations = { BUSINESS_SPRING_CONFIG_FILE,
|
@ContextConfiguration(locations = { BUSINESS_SPRING_CONFIG_FILE,
|
||||||
|
|
@ -177,6 +175,7 @@ public class ResourceServiceTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testListWorkers() throws Exception {
|
public void testListWorkers() throws Exception {
|
||||||
|
final int previousWorkers = resourceService.getWorkers().size();
|
||||||
ResourceGroup resourceGroup = new ResourceGroup();
|
ResourceGroup resourceGroup = new ResourceGroup();
|
||||||
Worker worker1 = new Worker("worker-1", "worker-2-surname",
|
Worker worker1 = new Worker("worker-1", "worker-2-surname",
|
||||||
"11111111A", 8);
|
"11111111A", 8);
|
||||||
|
|
@ -189,10 +188,10 @@ public class ResourceServiceTest {
|
||||||
resourceService.saveResource(resourceGroup);
|
resourceService.saveResource(resourceGroup);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Two workers has been created when saving the resource group",
|
"Two workers has been created when saving the resource group",
|
||||||
2, resourceService.getWorkers().size());
|
previousWorkers + 2, resourceService.getWorkers().size());
|
||||||
resourceService.saveResource(worker3);
|
resourceService.saveResource(worker3);
|
||||||
assertEquals("Three workers has been created", 3, resourceService
|
assertEquals("Three workers has been created", previousWorkers + 3,
|
||||||
.getWorkers().size());
|
resourceService.getWorkers().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue