Leo/Backend/UnitTest #138
@ -27,6 +27,8 @@ import ovh.herisson.Clyde.Tables.Token;
|
||||
import ovh.herisson.Clyde.Tables.User;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static io.restassured.RestAssured.with;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
@ -111,4 +113,21 @@ public class UserControllerTest {
|
||||
with().header("Authorization", t.getToken()).when().request("GET", "/user").then().assertThat().statusCode(200).body("firstName",equalTo("hero"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void userPatchTest(){
|
||||
User herobrine = new User("brine","hero","herobrine@admin.com","in your WalLs","ShadowsLand",new Date(0), null,Role.Student,"test");
|
||||
userRepository.save(herobrine);
|
||||
|
||||
Token t = new Token(herobrine, tokenService.generateNewToken(), new Date());
|
||||
tokenRepository.save(t);
|
||||
|
||||
Map<String, Object> data = new HashMap<String, Object>();
|
||||
data.put("firstName", "test");
|
||||
|
||||
//Teste que le patch s'execute bien
|
||||
with().body(data).contentType(ContentType.JSON).header("Authorization", t.getToken()).when().request("PATCH", "/user").then().statusCode(200);
|
||||
|
||||
//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"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user