1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
|
public class TestUtilisateurDao extends AbstractTransactionalDataSourceSpringContextTests {
UtilisateurDao utilisateurDao;
//Start of user code membres de la classe
ProjetDao projetDao;
private Societe societe1;
private Societe societe2;
private Intervenant intervenant1;
private Intervenant intervenant2;
private Intervenant intervenant3;
private Projet projet1;
private Projet projet2;
private Projet projet3;
private Acces acces1;
private Acces acces2;
private Acces acces3;
private Acces acces4;
private Acces acces5;
private Action action1;
private Action action2;
private Action action3;
private Action action4;
private Action action5;
private Action action6;
private Action action7;
private Risque risque1;
private Risque risque2;
private Risque risque3;
private Risque risque4;
private Risque risque5;
private Risque risque6;
private Risque risque7;
private Risque risque8;
private Risque risque9;
private Admin admin1;
private Admin admin2;
private Habilitation habilitation1;
private Habilitation habilitation2;
//End of user code membres de la classe
public void testSauvegarderAcces() {
//Start of user code sauvegarderAcces
utilisateurDao.sauvegarderAcces(acces1);
Acces accesCharge = utilisateurDao.chargerAcces(acces1.getLogin());
assertTrue(accesCharge.equals(acces1));
//End of user code sauvegarderAcces
}
public void testRechercheAccesParIdIntervenant() {
//Start of user code rechercheAccesParIdIntervenant
utilisateurDao.sauvegarderIntervenant(intervenant2);
assert(utilisateurDao.rechercheAccesParIdIntervenant(intervenant2.getIdIntervenant()) == acces2);
//End of user code rechercheAccesParIdIntervenant
}
public void testChargerAcces() {
//Start of user code chargerAcces
utilisateurDao.sauvegarderAcces(acces1);
Acces accesCharge = utilisateurDao.chargerAcces(acces1.getLogin());
assert(accesCharge.equals(acces1));
//End of user code chargerAcces
}
public void testSupprimerAcces() {
//Start of user code supprimerAcces
utilisateurDao.sauvegarderAcces(acces1);
Acces accesCharge = utilisateurDao.chargerAcces(acces1.getLogin());
assertTrue(accesCharge.equals(acces1));
utilisateurDao.supprimerAcces(acces1.getLogin());
assert(utilisateurDao.chargerAcces(acces1.getLogin())==null);
//End of user code supprimerAcces
}
public void testToutLesIntervenants() {
//Start of user code toutLesIntervenants
//utilisateurDao.sauvegarderIntervenant(intervenant1);
//utilisateurDao.sauvegarderIntervenant(intervenant2);
//utilisateurDao.sauvegarderIntervenant(intervenant3);
//jdbcTemplate.execute("insert into intervenant value (1500,\'brian\', \'youss\', \'brain.youss@sii.fr\', \'chef\',\'0231228547\',\'0231228547\',\'GRT\',\'sparadrah\',true,\'interne\',10,\'interne\')");
ArrayList<Intervenant> intervenants = (ArrayList<Intervenant>) utilisateurDao.toutLesIntervenants();
logger.debug("XXXXXXXXXXXXXXXXXXreteerferf");
assertTrue(intervenants.size()==1
/*intervenants.contains(intervenant1)&&
intervenants.contains(intervenant2)&&
intervenants.contains(intervenant3)*/);
//End of user code toutLesIntervenants
}
public void testRechercheIntervenantsParNomIntervenant() {
//Start of user code rechercheIntervenantsParNomIntervenant
utilisateurDao.sauvegarderIntervenant(intervenant1);
utilisateurDao.sauvegarderIntervenant(intervenant2);
ArrayList<Intervenant> intervenants = (ArrayList<Intervenant>) utilisateurDao.rechercheIntervenantsParNomIntervenant(intervenant1.getNom());
assertTrue(
intervenants.contains(intervenant1)&&
intervenants.contains(intervenant2));
//End of user code rechercheIntervenantsParNomIntervenant
}
public void testSauvegarderIntervenant() {
//Start of user code sauvegarderIntervenant
utilisateurDao.sauvegarderIntervenant(intervenant1);
logger.debug("XXXXXXXXXXXXXXXXXXXXXXXXX"+countRowsInTable("intervenant"));
utilisateurDao.sauvegarderIntervenant(intervenant2);
utilisateurDao.sauvegarderIntervenant(intervenant3);
Intervenant intervenantCharge = utilisateurDao.chargerIntervenant(intervenant1.getIdIntervenant());
logger.debug("XXXXXXXXXXXXXXXXXXXXXXXXX"+jdbcTemplate.queryForInt("select count(*) from intervenant"));
assertTrue(jdbcTemplate.queryForInt("select count(*) from intervenant")== 3
/*intervenantCharge.equals(intervenant1)&&
utilisateurDao.chargerAcces(acces1.getLogin()).equals(acces1)
*/);
//End of user code sauvegarderIntervenant
}
public void testRechercherIntervenantsInternes() {
//Start of user code rechercherIntervenantsInternes
utilisateurDao.sauvegarderIntervenant(intervenant1);
utilisateurDao.sauvegarderIntervenant(intervenant2);
utilisateurDao.sauvegarderIntervenant(intervenant3);
ArrayList<Intervenant> listeInternes = (ArrayList<Intervenant>) utilisateurDao.rechercherIntervenantsInternes();
assertTrue(
listeInternes.contains(intervenant1)&&
listeInternes.contains(intervenant2));
//End of user code rechercherIntervenantsInternes
}
public void testRechercherIntervenantsParProjet() {
//Start of user code rechercherIntervenantsParProjet
utilisateurDao.sauvegarderIntervenant(intervenant1);
utilisateurDao.sauvegarderIntervenant(intervenant2);
utilisateurDao.sauvegarderIntervenant(intervenant3);
projetDao.sauvegarderProjet(projet1);
projetDao.sauvegarderHabilitation(habilitation1);
projetDao.sauvegarderHabilitation(habilitation2);
ArrayList<Intervenant> listesIntervenants = (ArrayList<Intervenant>) utilisateurDao.rechercherIntervenantsParProjet(projet1.getNumOlga());
assertTrue(
listesIntervenants.contains(intervenant3)&&
listesIntervenants.contains(intervenant1)
);
//End of user code rechercherIntervenantsParProjet
}
public void testRechercheIntervenantParPrenomNom() {
//Start of user code rechercheIntervenantParPrenomNom
//TODO : le code de la fonction
assertTrue(true);
//End of user code rechercheIntervenantParPrenomNom
}
public void testChargerIntervenant() {
//Start of user code chargerIntervenant
utilisateurDao.sauvegarderIntervenant(intervenant1);
utilisateurDao.sauvegarderIntervenant(intervenant2);
utilisateurDao.sauvegarderIntervenant(intervenant3);
Intervenant intervenantCharge = utilisateurDao.chargerIntervenant(intervenant1.getIdIntervenant());
logger.debug("XXXXXXXXXXXXXXXXXXXXXXXXX"+utilisateurDao.chargerAcces(acces1.getLogin()).getRole());
assertTrue( intervenantCharge.equals(intervenant1)&&
utilisateurDao.chargerAcces(acces1.getLogin()).equals(acces1)
);
//End of user code chargerIntervenant
}
public void testSauvegarderAdmin() {
//Start of user code sauvegarderAdmin
utilisateurDao.sauvegarderAdmin(admin1);
utilisateurDao.sauvegarderAdmin(admin2);
Admin adminCharge = utilisateurDao.chargerAdmin(admin1.getIdAdmin());
assertTrue( adminCharge.equals(admin1)&&
utilisateurDao.chargerAcces(acces4.getLogin()).equals(acces4)
);
//End of user code sauvegarderAdmin
}
//Start of user code fonctions membres
@Override
protected void onSetUpBeforeTransaction() throws Exception {
super.onSetUpBeforeTransaction();
societe1 = new Societe("tyrex");
societe2 = new Societe("Stepmind");
acces1 = new Acces("brianYouss","brianIstheBEst","ras");
acces2 = new Acces("jeanMichel","jeanIstheBEst","rasToo");
acces3 = new Acces("reneBernard","reneIstheBEst","rasToo");
acces4 = new Acces("admin1","godasse","administrateur systeme");
acces5 = new Acces("admin2", "loldsfs","pdg");
intervenant1 = new Intervenant(1500,"brian", "youss", "brain.youss@sii.fr", "chef","0231228547","0231228547",acces1,societe1,"GRT","interne",true);
intervenant2 = new Intervenant(1501,"brian", "michel", "jeanMich@sii.fr", "ingenieur","0231247896","0231232547",acces2,societe1,"JMM","interne",true);
intervenant3 = new Intervenant(1502,"rene", "bernard", "reneBernard@sii.fr", "ingenieur","0231896547","0231998984",acces3,societe2,"RBR","externe",true);
admin1 = new Admin("Fontaine", "Benjamin","benji.fontaine@gmail.com", acces4,5000);
admin2 = new Admin("Wemaere", "François","francois.wemaere@gmail.com", acces5,5001);
projet1 = new Projet("toto",3000,societe1,"Externe SII",intervenant1,10);
projet2 = new Projet("titi",3300,societe1,"Interne SII",intervenant2,10);
projet3 = new Projet("tutu",3600,societe2,"Interne SII",intervenant3,10);
habilitation1 = new Habilitation(7542);
habilitation1.setIntervenant(intervenant1);
habilitation1.setProjet(projet1);
habilitation2 = new Habilitation(7541);
habilitation1.setIntervenant(intervenant3);
habilitation1.setProjet(projet1);
action1 = new Action();
action1.setIdAction(1520);
action1.setDateCreation(new DateTime());
action1.setDateEcheance(new DateTime().plusDays(14));
action1.setIntituleAction("TrucBidule");
action1.setCreateur(intervenant1);
action1.setEtat("enCours");
action1.setImportance("superImportante");
action1.setOrigine("revueRisque666");
//action1.setProjet(projet1);
action1.setVisibiliteClient(true);
action1.setResponsable(intervenant1);
action2 = new Action("revueCodeProjetTiti",new DateTime().plusDays(30),intervenant1,"important","enCours","revueRisque543",false,intervenant1, new DateTime().plusDays(10),10001);
action3 = new Action("truc",new DateTime().plusDays(60),intervenant1,"anecdotique","terminee","revueRisque54",true,intervenant3, new DateTime().plusDays(7),10002);
action4 = new Action("action4",new DateTime().plusDays(30),intervenant2,"rasant","fini","revueRisque10",true,intervenant1, new DateTime().plusDays(1),10003);
action5 = new Action("action5",new DateTime().plusDays(40),intervenant1,"important","enCours","revueRisque15",false,intervenant3, new DateTime().plusDays(2),10004);
action6 = new Action("action6",new DateTime().plusDays(50),intervenant3,"important","enCours","revueRisque20",true,intervenant3, new DateTime().plusDays(3),10005);
action7 = new Action("action7",new DateTime().plusDays(60),intervenant1,"important","fini","revueRisque25",false,intervenant2, new DateTime().plusDays(4),10006);
}
//accesseur utilise par Spring
public void setProjetDao( ProjetDao projetDao){
this.projetDao = projetDao;
}
//End of user code fonctions membres
//accesseur utilise par Spring
public void setUtilisateurDao( UtilisateurDao utilisateurDao){
this.utilisateurDao = utilisateurDao;
}
protected String[] getConfigLocations() {
return new String[] { "classpath:ApplicationContext-Hibernate.xml",
"classpath:ApplicationContext-Dao.xml" };
} |
Partager