Leo/Backend/UnitTest #138
@ -11,6 +11,4 @@ import java.util.ArrayList;
|
||||
public interface FileRepository extends CrudRepository<StorageFile,Long> {
|
||||
public StorageFile getStorageFileByName(String name);
|
||||
|
||||
@Query("select s from StorageFile s")
|
||||
public ArrayList<StorageFile> findAll();
|
||||
}
|
||||
|
||||
|
@ -132,4 +132,18 @@ public class UserControllerTest {
|
||||
//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"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void UserDeleteTest(){
|
||||
User god = new User("god","god","admin@admin.com","everywhere","every",new Date(0), null, Role.Admin,"goddoesntneedpassword");
|
||||
Token godToken = new Token(god, tokenService.generateNewToken(), new Date());
|
||||
userRepository.save(god);
|
||||
tokenService.saveToken(godToken);
|
||||
|
||||
User herobrine = new User("brine","hero","herobrine@admin.com","in your WalLs","ShadowsLand",new Date(0), null,Role.Student,"test");
|
||||
userRepository.save(herobrine);
|
||||
|
||||
with().header("Authorization", godToken.getToken()).pathParam("id", herobrine.getRegNo()).when().request("DELETE", "/user/{id}").then().statusCode(200);
|
||||
Assert.assertEquals(userRepository.existsById(herobrine.getRegNo()), false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user
pas besoin c'est déjà implémenté de base
bien vu c'est delete