Skip to content

Commit

Permalink
test missions
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Kelian committed Dec 10, 2023
1 parent ecbd195 commit bdc4641
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 8 deletions.
25 changes: 25 additions & 0 deletions src/main/java/controller/Controller.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,29 @@ public static String completeMission(int idMission) {
}
return completeMissionStatus;
}

public static int getIdOfUser(String email) {
int id = 0;
try {
String getIdRequest = "SELECT IdUser FROM USER WHERE Email = '" + email + "'";
ResultSet idRS = bdd.state.executeQuery(getIdRequest);
while (idRS.next()) {
id = idRS.getInt("IdUser");
}
}
catch (SQLException e) {
e.printStackTrace();
}
return id;
}

public static void deleteUserByName(String name) {
try {
String deleteUserQuery = "DELETE FROM USER WHERE UserFirstName = '" + name + "'";
bdd.state.executeUpdate(deleteUserQuery);
}
catch (SQLException e) {
e.printStackTrace();
}
}
}
8 changes: 0 additions & 8 deletions src/test/java/model/AppTest.java

This file was deleted.

43 changes: 43 additions & 0 deletions src/test/java/model/MissionTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package model;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MissionTest {

@Test
public void testGetters() {
Mission mission = new Mission(1, "Test Mission", "Test Description", "2023-01-01 18:00:00", 2, "Pending", 3);

assertEquals(1, mission.getIdMission());
assertEquals("Test Mission", mission.getTitle());
assertEquals("Test Description", mission.getDescription());
assertEquals("2023-01-01 18:00:00", mission.getDateTime());
assertEquals(2, mission.getIdNeeder());
assertEquals("Pending", mission.getStatus().name());
assertEquals(3, mission.getIdHelper());
}

@Test
public void testMissionConstructor() {
Mission mission = new Mission(1, "Test Mission", "Test Description", "2023-01-01 18:00:00", 2, "Pending", 3);

assertEquals(1, mission.getIdMission());
assertEquals("Test Mission", mission.getTitle());
assertEquals("Test Description", mission.getDescription());
assertEquals("2023-01-01 18:00:00", mission.getDateTime());
assertEquals(2, mission.getIdNeeder());
assertEquals("Pending", mission.getStatus().name());
assertEquals(3, mission.getIdHelper());
}

@Test
public void testToString() {
Mission mission = new Mission(1, "Test Mission", "Test Description", "2023-01-01 18:00:00", 2, "Pending", 3);

String expectedToString = "Mission{idMission=1, title='Test Mission', description='Test Description', date='2023-01-01 18:00:00', idNeeder=2, idHelper=3, status=Pending}";
assertEquals(expectedToString, mission.toString());
}

}

0 comments on commit bdc4641

Please sign in to comment.