Commit 8c9455f9 authored by Matija Obreza's avatar Matija Obreza

Updated code and tests to work with updated Spring MVC

parent b188e6bd
......@@ -192,7 +192,7 @@ public class CropsController extends RestController {
* @throws AuthorizationException
*/
@RequestMapping(value = "/rebuild", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody String rebuild() {
public @ResponseBody ApiResult rebuild() {
cropService.rebuildTaxonomies();
return JSON_OK;
}
......@@ -204,7 +204,7 @@ public class CropsController extends RestController {
* @throws AuthorizationException
*/
@RequestMapping(value = "{shortName}/rebuild", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody String rebuildCrop(@PathVariable("shortName") String shortName) {
public @ResponseBody ApiResult rebuildCrop(@PathVariable("shortName") String shortName) {
LOG.info("Updating crop rules for " + shortName);
final Crop crop = cropService.getCrop(shortName);
if (crop == null)
......
......@@ -71,7 +71,7 @@ public class OAuthManagementController extends RequestsController {
@RequestMapping("/token/at/{tokenId}/remove")
@PreAuthorize("hasRole('ADMINISTRATOR')")
@ResponseBody
public String removeAccessToken(@PathVariable("tokenId") long tokenId) {
public ApiResult removeAccessToken(@PathVariable("tokenId") long tokenId) {
tokenStore.removeAccessToken(tokenId);
return JSON_OK;
}
......@@ -79,7 +79,7 @@ public class OAuthManagementController extends RequestsController {
@PreAuthorize("hasRole('ADMINISTRATOR')")
@RequestMapping("/token/rt/{tokenId}/remove")
@ResponseBody
public String removeRefreshToken(@PathVariable("tokenId") long tokenId) {
public ApiResult removeRefreshToken(@PathVariable("tokenId") long tokenId) {
tokenStore.removeRefreshToken(tokenId);
return JSON_OK;
......@@ -88,7 +88,7 @@ public class OAuthManagementController extends RequestsController {
@PreAuthorize("hasRole('ADMINISTRATOR')")
@RequestMapping("/token/{clientId:.+}/remove-all-at")
@ResponseBody
public String removeAllAccessTokens(@PathVariable("clientId") String clientId) {
public ApiResult removeAllAccessTokens(@PathVariable("clientId") String clientId) {
final Collection<OAuth2AccessToken> tokens = tokenStore.findTokensByClientId(clientId);
for (final OAuth2AccessToken token : tokens) {
......@@ -101,7 +101,7 @@ public class OAuthManagementController extends RequestsController {
@PreAuthorize("hasRole('ADMINISTRATOR')")
@RequestMapping("/token/{clientId:.+}/remove-all-rt")
@ResponseBody
public String removeAllRefreshTokens(@PathVariable("clientId") String clientId) {
public ApiResult removeAllRefreshTokens(@PathVariable("clientId") String clientId) {
final Collection<OAuthRefreshToken> tokens = tokenStore.findRefreshTokensByClientId(clientId);
for (final OAuthRefreshToken token : tokens) {
......@@ -144,7 +144,7 @@ public class OAuthManagementController extends RequestsController {
@PreAuthorize("hasAnyRole('VETTEDUSER','ADMINISTRATOR')")
@RequestMapping(value = "/delete-client", method = RequestMethod.POST)
@ResponseBody
public String deleteClient(@RequestBody OAuthClientDetails requestClient) {
public ApiResult deleteClient(@RequestBody OAuthClientDetails requestClient) {
final OAuthClientDetails clientDetails = clientDetailsService.getClientDetails(requestClient.getId());
LOG.info("Deleting client " + clientDetails.getClientId());
clientDetailsService.removeClient(clientDetails);
......
......@@ -35,8 +35,16 @@ import org.springframework.web.bind.annotation.ResponseBody;
public abstract class RestController {
protected final Log LOG = LogFactory.getLog(getClass());
protected static final String JSON_OK = "{\"result\":true}";
protected static final ApiResult JSON_OK = new ApiResult(true);
public static class ApiResult {
public boolean result = false;
public ApiResult(boolean b) {
result=b;
}
}
public RestController() {
super();
}
......
......@@ -110,7 +110,7 @@ public class UsersController extends RestController {
@RequestMapping(value = "/user/data", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public String updateData(@RequestBody UserChangedDataJson userData) throws PasswordPolicyException, UserException {
public ApiResult updateData(@RequestBody UserChangedDataJson userData) throws PasswordPolicyException, UserException {
final User user = userService.getUserByUuid(userData.getUuid());
if (user == null) {
......@@ -150,7 +150,7 @@ public class UsersController extends RestController {
@RequestMapping(value = "/user/roles", method = RequestMethod.POST, consumes = {MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public String updateRoles(@RequestBody UserChangedDataJson userData) {
public ApiResult updateRoles(@RequestBody UserChangedDataJson userData) {
final User user = userService.getUserByUuid(userData.getUuid());
if (user == null) {
throw new ResourceNotFoundException();
......@@ -162,7 +162,7 @@ public class UsersController extends RestController {
@RequestMapping(value = "user/{uuid:.+}/send", method = RequestMethod.GET)
@ResponseBody
public String sendEmail(@PathVariable("uuid") String uuid) {
public ApiResult sendEmail(@PathVariable("uuid") String uuid) {
final User user = userService.getUserByUuid(uuid);
emailVerificationService.sendVerificationEmail(user);
......@@ -172,7 +172,7 @@ public class UsersController extends RestController {
@RequestMapping("user/{uuid:.+}/vetted-user")
@ResponseBody
public String addRoleVettedUser(@PathVariable("uuid") String uuid) {
public ApiResult addRoleVettedUser(@PathVariable("uuid") String uuid) {
userService.addVettedUserRole(uuid);
return JSON_OK;
}
......
......@@ -99,7 +99,7 @@ public class ApiCropsTest extends AbstractRestTest {
public void listCropsTest() throws Exception {
LOG.info("Start test-method listCropsTest");
mockMvc.perform(get("/api/v0/crops").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON))
mockMvc.perform(get("/api/v0/crops").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andExpect(jsonPath("$", hasSize(1))).andExpect(jsonPath("$[0].id", is(notNullValue()))).andExpect(jsonPath("$[0].version", is(0)))
.andExpect(jsonPath("$[0].shortName", is("maize"))).andExpect(jsonPath("$[0].i18n", is(nullValue()))).andExpect(jsonPath("$[0].name", is("Maize")))
.andExpect(jsonPath("$[0].description", is("Crop description in EN"))).andDo(document("crop-list"));
......@@ -111,12 +111,12 @@ public class ApiCropsTest extends AbstractRestTest {
public void createCropTest() throws Exception {
LOG.info("Start test-method createCropTest");
mockMvc.perform(post("/api/v0/crops").contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(new Object() {
mockMvc.perform(post("/api/v0/crops").contentType(MediaType.APPLICATION_JSON_UTF8).content(objectMapper.writeValueAsString(new Object() {
public String shortName = "rice";
public String name = "Rice";
public String description = "Crop description in EN";
public String[] otherNames = { "ris", "riž" };
}))).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$.id", is(notNullValue())))
}))).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$.id", is(notNullValue())))
.andExpect(jsonPath("$.version", is(0))).andExpect(jsonPath("$.shortName", is("rice"))).andExpect(jsonPath("$.i18n", is(nullValue())))
.andExpect(jsonPath("$.name", is("Rice"))).andExpect(jsonPath("$.description", is("Crop description in EN")))
.andDo(document("crop-create",
......@@ -138,8 +138,8 @@ public class ApiCropsTest extends AbstractRestTest {
public void getCropTest() throws Exception {
LOG.info("Start test-method getCropTest");
mockMvc.perform(get("/api/v0/crops/{shortName}", crop.getShortName()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$.id", is(notNullValue()))).andExpect(jsonPath("$.version", is(0)))
mockMvc.perform(get("/api/v0/crops/{shortName}", crop.getShortName()).contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$.id", is(notNullValue()))).andExpect(jsonPath("$.version", is(0)))
.andExpect(jsonPath("$.shortName", is("maize"))).andExpect(jsonPath("$.i18n", is(nullValue()))).andExpect(jsonPath("$.name", is("Maize")))
.andExpect(jsonPath("$.description", is("Crop description in EN")))
.andDo(document("crop-get", pathParameters(parameterWithName("shortName").description("Crop short name or code (e.g. maize)")),
......@@ -160,8 +160,8 @@ public class ApiCropsTest extends AbstractRestTest {
createCropTest();
mockMvc.perform(delete("/api/v0/crops/{shortName}", "rice").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$.id", is(nullValue()))).andExpect(jsonPath("$.version", is(0)))
mockMvc.perform(delete("/api/v0/crops/{shortName}", "rice").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$.id", is(nullValue()))).andExpect(jsonPath("$.version", is(0)))
.andExpect(jsonPath("$.shortName", is("rice"))).andExpect(jsonPath("$.i18n", is(nullValue()))).andExpect(jsonPath("$.name", is("Rice")))
.andExpect(jsonPath("$.description", is("Crop description in EN")))
.andDo(document("crop-delete", pathParameters(parameterWithName("shortName").description("Crop short name or code (e.g. maize)"))));
......@@ -173,8 +173,8 @@ public class ApiCropsTest extends AbstractRestTest {
public void getCropDescriptorsTest() throws Exception {
LOG.info("Start test-method getCropDescriptorsTest");
mockMvc.perform(get("/api/v0/crops/{shortName}/descriptors", crop.getShortName()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$.content", hasSize(0)))
mockMvc.perform(get("/api/v0/crops/{shortName}/descriptors", crop.getShortName()).contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$.content", hasSize(0)))
// .andExpect(jsonPath("$.lastPage", is(true)))
.andExpect(jsonPath("$.numberOfElements", is(0))).andExpect(jsonPath("$.totalElements", is(0))).andExpect(jsonPath("$.number", is(0)))
// .andExpect(jsonPath("$.firstPage", is(true)))
......@@ -188,8 +188,8 @@ public class ApiCropsTest extends AbstractRestTest {
public void getCropRulesTest() throws Exception {
LOG.info("Start test-method getCropRulesTest");
mockMvc.perform(get("/api/v0/crops/{shortName}/rules", crop.getShortName()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$", hasSize(1))).andExpect(jsonPath("$[0].id", is(notNullValue())))
mockMvc.perform(get("/api/v0/crops/{shortName}/rules", crop.getShortName()).contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$", hasSize(1))).andExpect(jsonPath("$[0].id", is(notNullValue())))
.andExpect(jsonPath("$[0].included", is(true))).andExpect(jsonPath("$[0].genus", is("Zea"))).andExpect(jsonPath("$[0].species", is("mays")))
.andExpect(jsonPath("$[0].subtaxa", is(nullValue())))
.andDo(document("crop-rules-list", pathParameters(parameterWithName("shortName").description("Crop short name or code (e.g. maize)"))));
......@@ -212,8 +212,8 @@ public class ApiCropsTest extends AbstractRestTest {
cropRule.setSubtaxa("var. foobaria");
cropRules.add(cropRule);
mockMvc.perform(put("/api/v0/crops/{shortName}/rules", crop.getShortName()).contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsString(cropRules)))
.andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$", hasSize(1)))
mockMvc.perform(put("/api/v0/crops/{shortName}/rules", crop.getShortName()).contentType(MediaType.APPLICATION_JSON_UTF8).content(objectMapper.writeValueAsString(cropRules)))
.andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$", hasSize(1)))
.andExpect(jsonPath("$[0].id", is(notNullValue()))).andExpect(jsonPath("$[0].included", is(true))).andExpect(jsonPath("$[0].genus", is("Zea")))
.andExpect(jsonPath("$[0].species", is("mays"))).andExpect(jsonPath("$[0].subtaxa", is("var. foobaria")))
.andDo(document("crop-rules-update", pathParameters(parameterWithName("shortName").description("Crop short name or code (e.g. maize)")),
......@@ -229,8 +229,8 @@ public class ApiCropsTest extends AbstractRestTest {
public void getCropTaxaTest() throws Exception {
LOG.info("Start test-method getCropTaxaTest");
mockMvc.perform(get("/api/v0/crops/{shortName}/taxa", crop.getShortName()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(jsonPath("$.content", hasSize(0)))
mockMvc.perform(get("/api/v0/crops/{shortName}/taxa", crop.getShortName()).contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(jsonPath("$.content", hasSize(0)))
// .andExpect(jsonPath("$.lastPage", is(true)))
.andExpect(jsonPath("$.numberOfElements", is(0))).andExpect(jsonPath("$.totalElements", is(0))).andExpect(jsonPath("$.number", is(0)))
// .andExpect(jsonPath("$.firstPage", is(true)))
......@@ -249,8 +249,8 @@ public class ApiCropsTest extends AbstractRestTest {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(JSON_OK);
mockMvc.perform(post("/api/v0/crops/rebuild").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(content().string(objectMapper.writeValueAsString(jsonNode)));
mockMvc.perform(post("/api/v0/crops/rebuild").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(content().string(objectMapper.writeValueAsString(jsonNode)));
LOG.info("Test rebuildTest passed");
}
......@@ -264,8 +264,8 @@ public class ApiCropsTest extends AbstractRestTest {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode jsonNode = objectMapper.readTree(JSON_OK);
mockMvc.perform(post("/api/v0/crops/{shortName}/rebuild", crop.getShortName()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andExpect(content().string(objectMapper.writeValueAsString(jsonNode)));
mockMvc.perform(post("/api/v0/crops/{shortName}/rebuild", crop.getShortName()).contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(content().string(objectMapper.writeValueAsString(jsonNode)));
LOG.info("Test rebuildCropTest passed");
}
......
......@@ -114,8 +114,8 @@ public class ApiImagesDocsTest extends AbstractRestTest {
@Test
public void testListGalleries() throws UnsupportedEncodingException, Exception {
mockMvc.perform(get("/api/v0/img/{instCode}/_galleries", TEST_INSTCODE).param("page", "1").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andDo(r -> {
mockMvc.perform(get("/api/v0/img/{instCode}/_galleries", TEST_INSTCODE).param("page", "1").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(r -> {
LOG.info("Institute galleries: " + r.getResponse().getContentAsString());
}).andExpect(jsonPath("$.content", hasSize(0))).andExpect(jsonPath("$.totalElements", is(0))).andExpect(jsonPath("$.last", is(true)))
.andDo(document("img-instgallery-list", pathParameters(parameterWithName("instCode").description("Institute WIEWS code (e.g. NGA039)")),
......@@ -131,7 +131,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
public void testUploadImage1() throws UnsupportedEncodingException, Exception {
final StringBuilder sb = new StringBuilder();
mockMvc.perform(put("/api/v0/img/{instCode}/acn/{acceNumb}/", TEST_INSTCODE, ACCENUMB).param("originalFilename", image1.getOriginalFilename()).contentType(MediaType.IMAGE_JPEG_VALUE)
.content(image1.getImageBytes())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andDo(r -> {
.content(image1.getImageBytes())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(r -> {
LOG.info("Image PUT response: " + r.getResponse().getContentAsString());
RepositoryImage ri = objectMapper.readValue(r.getResponse().getContentAsString(), RepositoryImage.class);
LOG.info(ri);
......@@ -174,8 +174,8 @@ public class ApiImagesDocsTest extends AbstractRestTest {
ri.setSubject(ACCENUMB);
ri.setTitle("Leaf of " + ACCENUMB);
ri.setExtent("4000x2000 pixels, 10MB");
mockMvc.perform(put("/api/v0/img/{instCode}/acn/{acceNumb}/{uuid}/_metadata", TEST_INSTCODE, ACCENUMB, uuid).contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.content(objectMapper.writeValueAsString(ri))).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andDo(r -> {
mockMvc.perform(put("/api/v0/img/{instCode}/acn/{acceNumb}/{uuid}/_metadata", TEST_INSTCODE, ACCENUMB, uuid).contentType(MediaType.APPLICATION_JSON_UTF8)
.content(objectMapper.writeValueAsString(ri))).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(r -> {
LOG.info("Image metadata put: " + r.getResponse().getContentAsString());
})
.andDo(document("img-instgallery-metadata-put",
......@@ -220,7 +220,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("dateSubmitted").ignored(), fieldWithPath("modified").ignored())));
mockMvc.perform(get("/api/v0/img/{instCode}/acn/{acceNumb}/{uuid}/_metadata", TEST_INSTCODE, ACCENUMB, uuid)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andDo(r -> {
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(r -> {
LOG.info("Image metadata: " + r.getResponse().getContentAsString());
})
.andDo(document("img-instgallery-metadata-get",
......@@ -244,7 +244,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(), fieldWithPath("dateSubmitted").ignored(),
fieldWithPath("modified").ignored())));
mockMvc.perform(get("/api/v0/img/{instCode}/acn/{acceNumb}/_list", TEST_INSTCODE, ACCENUMB)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)).andDo(r -> {
mockMvc.perform(get("/api/v0/img/{instCode}/acn/{acceNumb}/_list", TEST_INSTCODE, ACCENUMB)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(r -> {
LOG.info("Listing image UUIDs: " + r.getResponse().getContentAsString());
}).andDo(document("img-instgallery-accelist",
pathParameters(parameterWithName("instCode").description("Institute WIEWS code (e.g. NGA039)"), parameterWithName("acceNumb").description("Existing ACCENUMB in the institute"))));
......
......@@ -98,7 +98,7 @@ public class ApiRequestsDocsTest extends AbstractRestTest {
@Test
public void listRequestsTest() throws Exception {
mockMvc.perform(get("/api/v0/requests/{instCode}", TEST_INSTCODE).param("page", "0")).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andDo(r -> {
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(r -> {
System.err.println(r.getResponse().getContentAsString());
}).andExpect(jsonPath("$.size", is(10))).andExpect(jsonPath("$.first", is(true)))
.andDo(document("requests-inst-list", pathParameters(parameterWithName("instCode").description("Institute WIEWS code (e.g. NGA039)")),
......@@ -114,8 +114,8 @@ public class ApiRequestsDocsTest extends AbstractRestTest {
// /requests/{instCode}/r/{uuid:.{36}}
@Test
public void getRequestInfoTest() throws Exception {
mockMvc.perform(get("/api/v0/requests//{instCode}/r/{uuid}", TEST_INSTCODE, requestUuid.toString()).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON)).andDo(r -> {
mockMvc.perform(get("/api/v0/requests//{instCode}/r/{uuid}", TEST_INSTCODE, requestUuid.toString()).contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(r -> {
System.err.println(r.getResponse().getContentAsString());
})
// .andExpect(jsonPath("$", hasSize(1)))
......
......@@ -96,7 +96,7 @@ public class BrAPITest extends AbstractRestTest {
public void crops() throws Exception {
LOG.info("Start test-method listCropsTest");
mockMvc.perform(get("/brapi/v1/crops?page=0&pageSize=2").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON))
mockMvc.perform(get("/brapi/v1/crops?page=0&pageSize=2").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
// peek
.andDo(r -> {
System.err.println(r.getResponse().getContentAsString());
......@@ -121,8 +121,8 @@ public class BrAPITest extends AbstractRestTest {
@Test
public void germplasmSearch() throws Exception {
mockMvc.perform(get("/brapi/v1/germplasm-search?page=0&pageSize=2&germplasmName=&germplasmDbId=&germplasmPUI=").contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
mockMvc.perform(get("/brapi/v1/germplasm-search?page=0&pageSize=2&germplasmName=&germplasmDbId=&germplasmPUI=").contentType(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
// peek
.andDo(r -> {
System.err.println(r.getResponse().getContentAsString());
......@@ -150,9 +150,9 @@ public class BrAPITest extends AbstractRestTest {
@Test
public void germplasm() throws Exception {
mockMvc.perform(get("/brapi/v1/germplasm/{germplasmID}", "cd8c1217-4503-4859-813b-32251f0c8eba").contentType(MediaType.APPLICATION_JSON))
mockMvc.perform(get("/brapi/v1/germplasm/{germplasmID}", "cd8c1217-4503-4859-813b-32251f0c8eba").contentType(MediaType.APPLICATION_JSON_UTF8))
// response
// .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON))
// .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
// peek
.andDo(r -> {
System.err.println(r.getResponse().getContentAsString());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment