PMT-37: implement endpoint testing
All checks were successful
Quality Check / Validate OAS (push) Successful in 33s
Quality Check / Linting (push) Successful in 1m10s
Quality Check / Static Analysis (push) Successful in 1m17s
Quality Check / Testing (push) Successful in 1m17s
Quality Check / Validate OAS (pull_request) Successful in 32s
Quality Check / Linting (pull_request) Successful in 1m10s
Quality Check / Static Analysis (pull_request) Successful in 1m20s
Quality Check / Testing (pull_request) Successful in 1m19s

This commit is contained in:
Ole Kück 2024-10-24 09:52:07 +02:00
parent 3dd06fbf0c
commit 7fc105308a
Signed by: SZUT-Ole
GPG key ID: 0A1DF1B37C4A1E4C

View file

@ -0,0 +1,37 @@
package de.hmmh.pmt.project;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import java.util.Map;
import org.junit.jupiter.api.Test;
import de.hmmh.pmt.IntegrationTest;
import de.hmmh.pmt.db.Project;
public class GetProjectInfoTest extends IntegrationTest {
@Test
void noProject() throws Exception {
mvc
.perform(get(baseUri + "/project/1"))
.andExpect(status().isNotFound());
}
@Test
void getProjectInfo() throws Exception {
Map<String, Project> allProjects = createTestProjectData();
Project spaceStation = allProjects.get("space-station");
mvc
.perform(get(baseUri + "/project/" +spaceStation.getId()))
.andExpect(status().isOk())
.andExpect(jsonPath("$.id").value(spaceStation.getId()))
.andExpect(jsonPath("$.name").value(spaceStation.getName()))
.andExpect(jsonPath("$.goal").value(spaceStation.getGoal()))
.andExpect(jsonPath("$.customerId").value(spaceStation.getCustomerId()))
.andExpect(jsonPath("$.administratorId").value(spaceStation.getAdministratorId()))
;
}
}