Commit 1290ab4d8ad7d37411770f3f4ecfcc8fcfc37af4

Authored by Ronan
1 parent cd85c894

Correcting GetDomainJob

skilldr-service/src/main/java/eu/totoandco/business/JobManager.java
... ... @@ -68,6 +68,6 @@ public class JobManager {
68 68 * @return List of Jobs
69 69 */
70 70 public List<Job> getAllDomainJob(int idDomain) {
71   - return jobModel.search(Job.class, "idDomain", idDomain);
  71 + return jobModel.search(Job.class, "domain", idDomain);
72 72 }
73 73 }
... ...
skilldr-rs/src/test/java/e/totoandco/rs/JobGetDomainJobTest.java renamed to skilldr-service/src/test/java/eu/totoandco/business/JobGetDomainJobTest.java
... ... @@ -14,7 +14,7 @@
14 14 * that suggests the licensor endorses you or your use.
15 15 * No additional restrictions
16 16 */
17   -package e.totoandco.rs;
  17 +package eu.totoandco.business;
18 18  
19 19 import java.util.List;
20 20  
... ... @@ -31,8 +31,6 @@ import org.junit.Before;
31 31 import org.junit.Test;
32 32 import org.junit.runner.RunWith;
33 33  
34   -import eu.totoandco.business.JobManager;
35   -import eu.totoandco.business.SkillManager;
36 34 import eu.totoandco.data.Role;
37 35 import eu.totoandco.data.parameter.Parameter;
38 36 import eu.totoandco.entitymanager.ModelAccess;
... ... @@ -42,7 +40,7 @@ import eu.totoandco.model.Domain;
42 40 import eu.totoandco.model.Job;
43 41  
44 42 /**
45   - *
  43 + * Test getAllDomainJob based on an idDomain
46 44 * @author Ronan Presle (ronan.presle@ttmail.eu)
47 45 */
48 46 @RunWith(Arquillian.class)
... ... @@ -50,18 +48,17 @@ public class JobGetDomainJobTest {
50 48  
51 49 @Deployment
52 50 public static WebArchive createTestArchive() {
53   - WebArchive war = ShrinkWrap
  51 + return ShrinkWrap
54 52 .create(WebArchive.class, "test.war")
55 53 .addClasses(ModelAccess.class, UserAccess.class)
56 54 .addPackage(MessageException.class.getPackage())
57 55 .addPackage(Parameter.class.getPackage())
58   - .addPackage(Domain.class.getPackage())
  56 + .addPackage(Job.class.getPackage())
59 57 .addPackage(Role.class.getPackage())
60 58 .addPackage(SkillManager.class.getPackage())
61 59 .addAsResource(
62 60 new ClassLoaderAsset("META-INF/persistence.xml"),
63 61 "META-INF/persistence.xml");
64   - return war;
65 62 }
66 63  
67 64 @EJB
... ... @@ -70,6 +67,9 @@ public class JobGetDomainJobTest {
70 67 @EJB
71 68 ModelAccess<Domain> domainModel;
72 69  
  70 + @EJB
  71 + ModelAccess<Job> jobModel;
  72 +
73 73 Domain domain;
74 74 Job job1;
75 75 Job job2;
... ... @@ -78,17 +78,19 @@ public class JobGetDomainJobTest {
78 78 public void init() {
79 79 domain = new Domain("TestDomain");
80 80 domainModel.save(domain);
81   - jobManager.addJob("TestJob1", domain.getId());
82   - jobManager.addJob("TestJob2", domain.getId());
  81 + job1 = new Job("TestJob1", domain);
  82 + job2 = new Job("TestJob2", domain);
  83 + jobModel.save(job1);
  84 + jobModel.save(job2);
83 85 }
84 86  
85 87 @Test
86 88 public void test() {
87 89 List<Job> jobs = jobManager.getAllDomainJob(domain.getId());
88 90 Assert.assertNotNull("The found list is null", jobs);
89   - Assert.assertTrue("No skills found in database", jobs.size() != 0);
90   - Assert.assertTrue("Not all jobs retrieve from database", jobs.size() != 2);
91   - Assert.assertTrue("First skill is not the inserted one", jobs.get(0).equals(job1));
  91 + Assert.assertTrue("No skills found in database", !jobs.isEmpty());
  92 + Assert.assertTrue("Not all jobs retrieve from database", jobs.size() == 2);
  93 + Assert.assertTrue("First skill is not the inserted one", jobs.get(0).equals(job1) || jobs.get(0).equals(job2));
92 94 }
93 95  
94 96 @After
... ...
skilldr-service/src/test/java/eu/totoandco/business/UserGetSkillTest.java
... ... @@ -31,7 +31,6 @@ import org.junit.Before;
31 31 import org.junit.Test;
32 32 import org.junit.runner.RunWith;
33 33  
34   -import eu.totoandco.business.SkillManager;
35 34 import eu.totoandco.data.Role;
36 35 import eu.totoandco.data.parameter.Parameter;
37 36 import eu.totoandco.entitymanager.ModelAccess;
... ... @@ -110,7 +109,7 @@ public class UserGetSkillTest {
110 109 public void test() {
111 110 List<Skill> skills = userManager.getUserSkills(user.getId());
112 111 Assert.assertNotNull("The found list is null", skills);
113   - Assert.assertTrue("No skills found in database", skills.size() != 0);
  112 + Assert.assertTrue("No skills found in database", !skills.isEmpty());
114 113 Assert.assertTrue("First skill is not the inserted one", skills.get(0).equals(skill));
115 114 }
116 115  
... ...