From 7fc105308af62186ca1696ee017d588d6da22d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20K=C3=BCck?= Date: Thu, 24 Oct 2024 09:52:07 +0200 Subject: [PATCH] PMT-37: implement endpoint testing --- .../hmmh/pmt/project/GetProjectInfoTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/java/de/hmmh/pmt/project/GetProjectInfoTest.java diff --git a/src/test/java/de/hmmh/pmt/project/GetProjectInfoTest.java b/src/test/java/de/hmmh/pmt/project/GetProjectInfoTest.java new file mode 100644 index 0000000..b03f09d --- /dev/null +++ b/src/test/java/de/hmmh/pmt/project/GetProjectInfoTest.java @@ -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 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())) + ; + + } + +}