Leo/Backend/UnitTest #138

Merged
LeoMoulin merged 17 commits from Leo/Backend/UnitTest into master 2024-03-18 19:21:55 +01:00
2 changed files with 14 additions and 2 deletions
Showing only changes of commit c7f37b0854 - Show all commits

View File

@ -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();
}

pas besoin c'est déjà implémenté de base

pas besoin c'est déjà implémenté de base

bien vu c'est delete

bien vu c'est delete

View File

@ -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);
}
}