Skip to content

Commit

Permalink
Fix run_synthesis tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vedran-kasalica committed Aug 1, 2023
1 parent b8fcd4b commit 906e88f
Showing 1 changed file with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,34 @@ public class RestApeControllerTest {
@Autowired
private MockMvc mvc;

/**
* Test the getGreetings method.
*
* @throws Exception if the test fails
*/
@Test
public void getGreetings() throws Exception {
mvc.perform(MockMvcRequestBuilders.get("/").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().string(equalTo("Welcome to the RestApe API!")));
}

/**
* Test the getData method without a config_path parameter.
*
* @throws Exception if the call does not detect the missing parameter.
*/
@Test
public void getDataFail() throws Exception {
mvc.perform(MockMvcRequestBuilders.get("/get_data").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}

/**
* Test the getData method with a config_path parameter.
*
* @throws Exception if the test fails.
*/
@Test
public void getDataTest() throws Exception {
String path = "https://raw.githubusercontent.com/Workflomics/domain-annotations/main/MassSpectometry/config.json";
Expand All @@ -44,12 +59,22 @@ public void getDataTest() throws Exception {
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}

/**
* Test the getTools method without a config_path parameter.
*
* @throws Exception if the call does not detect the missing parameter.
*/
@Test
public void getToolsFail() throws Exception {
mvc.perform(MockMvcRequestBuilders.get("/get_tools").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}

/**
* Test the getTools method with a config_path parameter.
*
* @throws Exception if the test fails.
*/
@Test
public void getToolsTest() throws Exception {
String path = "https://raw.githubusercontent.com/Workflomics/domain-annotations/main/MassSpectometry/config.json";
Expand All @@ -59,9 +84,26 @@ public void getToolsTest() throws Exception {
.andExpect(content().contentType(MediaType.APPLICATION_JSON));
}

/**
* Test the runSynthesis method with GET instead of POST.
*
* @throws Exception if the call does not detect the that the call should be
* POST.
*/
@Test
public void runSynthesisFail() throws Exception {
public void runSynthesisGetFail() throws Exception {
mvc.perform(MockMvcRequestBuilders.get("/run_synthesis").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isMethodNotAllowed());
}

/**
* Test the runSynthesis method with POST, but without a confuguartion file.
*
* @throws Exception if the call does not detect the missing file.
*/
@Test
public void runSynthesisPostFail() throws Exception {
mvc.perform(MockMvcRequestBuilders.post("/run_synthesis").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isBadRequest());
}

Expand Down

0 comments on commit 906e88f

Please sign in to comment.