Leo/Backend/UnitTest #138

Merged
LeoMoulin merged 17 commits from Leo/Backend/UnitTest into master 2024-03-18 19:21:55 +01:00
Showing only changes of commit 9744bd973f - Show all commits

View File

@ -117,7 +117,7 @@ public class UserControllerTest {
@Test @Test
public void userPatchTest(){ public void userPatchTest(){
User herobrine = new User("brine","hero","herobrine@admin.com","in your WalLs","ShadowsLand",new Date(0), null,Role.Student,"test"); User herobrine = new User("brine","hero","herobrine@admin.com","in your WalLs","ShadowsLand",new Date(0), null,Role.Admin,"test");
userRepository.save(herobrine); userRepository.save(herobrine);
Token t = new Token(herobrine, tokenService.generateNewToken(), new Date()); Token t = new Token(herobrine, tokenService.generateNewToken(), new Date());
@ -127,7 +127,7 @@ public class UserControllerTest {
data.put("firstName", "test"); data.put("firstName", "test");
//Teste que le patch s'execute bien //Teste que le patch s'execute bien
with().body(data).contentType(ContentType.JSON).header("Authorization", t.getToken()).when().request("PATCH", "/user").then().statusCode(200); with().body(data).contentType(ContentType.JSON).header("Authorization", t.getToken()).pathParam("id", herobrine.getRegNo()).when().request("PATCH", "/user/{id}").then().statusCode(200);
//Teste que la donnée a bien été altérée //Teste que la donnée a bien été altérée
with().header("Authorization", t.getToken()).when().request("GET", "/user").then().body("firstName",equalTo("test")); with().header("Authorization", t.getToken()).when().request("GET", "/user").then().body("firstName",equalTo("test"));