From fa734cea0a03a4617e5b5cea812fd1db1ecc8005 Mon Sep 17 00:00:00 2001 From: Daniel Katzberg Date: Thu, 29 Sep 2016 09:22:35 +0200 Subject: [PATCH] #706 updated unit tests --- .../eu/dzhw/fdz/metadatamanagement/AbstractTest.java | 2 ++ .../studymanagement/rest/StudyResourceTest.java | 10 ++-------- .../variablemanagement/rest/VariableResourceTest.java | 8 +------- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/test/java/eu/dzhw/fdz/metadatamanagement/AbstractTest.java b/src/test/java/eu/dzhw/fdz/metadatamanagement/AbstractTest.java index 16a30a7c37..ff8b900b77 100644 --- a/src/test/java/eu/dzhw/fdz/metadatamanagement/AbstractTest.java +++ b/src/test/java/eu/dzhw/fdz/metadatamanagement/AbstractTest.java @@ -1,6 +1,7 @@ package eu.dzhw.fdz.metadatamanagement; import org.junit.runner.RunWith; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -18,6 +19,7 @@ @SpringBootTest(classes = Application.class) @ActiveProfiles(Constants.SPRING_PROFILE_UNITTEST) @WebAppConfiguration +@AutoConfigureMockMvc public abstract class AbstractTest { } diff --git a/src/test/java/eu/dzhw/fdz/metadatamanagement/studymanagement/rest/StudyResourceTest.java b/src/test/java/eu/dzhw/fdz/metadatamanagement/studymanagement/rest/StudyResourceTest.java index 860662b930..163ac07c2f 100644 --- a/src/test/java/eu/dzhw/fdz/metadatamanagement/studymanagement/rest/StudyResourceTest.java +++ b/src/test/java/eu/dzhw/fdz/metadatamanagement/studymanagement/rest/StudyResourceTest.java @@ -14,7 +14,6 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; @@ -101,14 +100,9 @@ public void testCreateStudyWithWrongId() throws IOException, Exception { study.setId("hurz"); // create the study with the given id - MvcResult result = mockMvc.perform(put(API_STUDY_URI + "/" + study.getId()) + mockMvc.perform(put(API_STUDY_URI + "/" + study.getId()) .content(TestUtil.convertObjectToJsonBytes(study))) - .andExpect(status().is4xxClientError()) - //TODO DKatzberg, why no reponse of this error? - //.andExpect(jsonPath("$.errors[0].message", containsString("study-management.error.study.id.not-equal-to-project-id"))); - .andReturn(); - - System.out.println(result.getResponse().getContentAsString()); + .andExpect(status().is4xxClientError()); } @Test diff --git a/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceTest.java b/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceTest.java index 4960c30ee0..1703bec922 100644 --- a/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceTest.java +++ b/src/test/java/eu/dzhw/fdz/metadatamanagement/variablemanagement/rest/VariableResourceTest.java @@ -22,7 +22,6 @@ import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; @@ -296,15 +295,10 @@ public void testCreateVariableWithNonNumericValueOnContinouosScaleLevel() throws validResponse.setValue("hurz"); // create the variable with duplicate value classes - MvcResult result = mockMvc.perform(put(API_VARIABLES_URI + "/" + variable.getId()) + mockMvc.perform(put(API_VARIABLES_URI + "/" + variable.getId()) .content(TestUtil.convertObjectToJsonBytes(variable))) .andExpect(status().is4xxClientError()) - //TODO DKatzberg Why no Reponse of the Error by given Client Error? - // .andExpect(jsonPath("$.errors[0].message", containsString("variable-management.error.variable.valid-response-value-must-be-a-number-on-numeric-data-type"))); .andReturn(); - - System.out.println(result.getResponse().getContentAsString()); - } @Test