Commit 00f23a64 authored by Matija Obreza's avatar Matija Obreza

Updated JUnit tests to fix build

parent 101c9078
......@@ -101,7 +101,7 @@ public class CacheController extends RestController {
return JSON_OK;
}
@RequestMapping(method = RequestMethod.POST, value = "/clearCaches")
@RequestMapping(method = RequestMethod.POST, value = "/clearCaches", produces = { MediaType.APPLICATION_JSON_VALUE })
@PreAuthorize("hasRole('ADMINISTRATOR')")
public @ResponseBody Object clearCaches() {
for (String cacheName : cacheManager.getCacheNames()) {
......
......@@ -178,7 +178,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("width").description("Image width in pixels (autodetected)"), fieldWithPath("height").description("Image height in pixels (autodetected)"),
fieldWithPath("orientation").description("LANDSCAPE or PORTRAIT orientation of the image (autodetected)"),
// Ignored stuff
fieldWithPath("id").ignored(), fieldWithPath("title").ignored(), fieldWithPath("subject").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("_class").ignored(), fieldWithPath("id").ignored(), fieldWithPath("title").ignored(), fieldWithPath("subject").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("creator").ignored(), fieldWithPath("created").ignored(), fieldWithPath("rightsHolder").ignored(), fieldWithPath("accessRights").ignored(),
fieldWithPath("license").ignored(), fieldWithPath("extent").ignored(), fieldWithPath("bibliographicCitation").ignored(), fieldWithPath("createdDate").ignored(),
fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("lastModifiedBy").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(), fieldWithPath("dateSubmitted").ignored(),
......@@ -220,14 +220,12 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("extent").description("Size (e.g. bytes, pages, inches, etc.) or duration (e.g. hours, minutes, days, etc.) of a resource"),
fieldWithPath("bibliographicCitation").description("Formal bibliographic citation for the resource"),
// ignored
fieldWithPath("active").ignored(), fieldWithPath("id").ignored(), fieldWithPath("thumbnailPath").ignored(), fieldWithPath("url").ignored(), fieldWithPath("storageFullPath").ignored()),
fieldWithPath("active").ignored(), fieldWithPath("_class").ignored(), fieldWithPath("id").ignored(), fieldWithPath("thumbnailPath").ignored(), fieldWithPath("url").ignored(), fieldWithPath("storageFullPath").ignored()),
responseFields(fieldWithPath("uuid").ignored(), fieldWithPath("originalFilename").description("The original filename that you have provided"),
fieldWithPath("extension").ignored(), fieldWithPath("contentType").ignored(), fieldWithPath("path").ignored(),
fieldWithPath("filename").ignored(),
fieldWithPath("metadataFilename").ignored(),
fieldWithPath("url").ignored(), fieldWithPath("sha1Sum").ignored(), fieldWithPath("md5Sum").ignored(),
// Ignored stuff
fieldWithPath("id").ignored(),
// Updated stuff
fieldWithPath("width").description("Image width in pixels (autodetected)"), fieldWithPath("height").description("Image height in pixels (autodetected)"),
fieldWithPath("orientation").description("LANDSCAPE or PORTRAIT orientation of the image (autodetected)"), fieldWithPath("format").description("Image format"),
......@@ -246,7 +244,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("bibliographicCitation").description("Formal bibliographic citation for the resource"),
fieldWithPath("size").description("Image size in bytes"),
// ignored
fieldWithPath("id").ignored(), fieldWithPath("version").ignored(),
fieldWithPath("_class").ignored(), fieldWithPath("id").ignored(), fieldWithPath("version").ignored(),
fieldWithPath("createdDate").ignored(), fieldWithPath("createdBy").ignored(), fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("lastModifiedBy").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(),
fieldWithPath("dateSubmitted").ignored(), fieldWithPath("modified").ignored(), fieldWithPath("active").ignored(), fieldWithPath("thumbnailPath").ignored(), fieldWithPath("url").ignored(), fieldWithPath("storageFullPath").ignored(), fieldWithPath("storagePath").ignored())));
......@@ -271,7 +269,7 @@ public class ApiImagesDocsTest extends AbstractRestTest {
fieldWithPath("orientation").description("LANDSCAPE or PORTRAIT orientation of the image (autodetected)"),
fieldWithPath("size").description("Image size in bytes"),
// Ignored stuff
fieldWithPath("id").ignored(), fieldWithPath("version").ignored(), fieldWithPath("title").ignored(), fieldWithPath("subject").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("_class").ignored(), fieldWithPath("id").ignored(), fieldWithPath("version").ignored(), fieldWithPath("title").ignored(), fieldWithPath("subject").ignored(), fieldWithPath("description").ignored(),
fieldWithPath("creator").ignored(), fieldWithPath("created").ignored(), fieldWithPath("rightsHolder").ignored(), fieldWithPath("accessRights").ignored(),
fieldWithPath("license").ignored(), fieldWithPath("extent").ignored(), fieldWithPath("bibliographicCitation").ignored(), fieldWithPath("createdDate").ignored(), fieldWithPath("createdBy").ignored(),
fieldWithPath("lastModifiedDate").ignored(), fieldWithPath("lastModifiedBy").ignored(), fieldWithPath("originalUrl").ignored(), fieldWithPath("dateRetrieved").ignored(), fieldWithPath("dateSubmitted").ignored(),
......
......@@ -17,6 +17,8 @@ package org.genesys2.tests.unit;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
......@@ -96,7 +98,7 @@ public class UserServiceTest extends AbstractServicesTest {
Pageable pageable = (Pageable) new PageRequest(0, 10, new Sort("email"));
List<User> users = userService.listUsers(pageable).getContent();
assertTrue(users.size() == 1);
assertThat("We should have only a SYSTEM and Admin user", users.size(), is(2));
}
@Test
......@@ -112,7 +114,7 @@ public class UserServiceTest extends AbstractServicesTest {
Page<UserWrapper> userWrappers = userService.listWrapped(startRow, pageSize);
assertTrue(userWrappers != null);
assertTrue(userWrappers.getContent().get(0).getEmail().equals(email));
assertThat(userWrappers.getContent().get(1).getEmail(), is(email));
}
@Test
......@@ -213,9 +215,10 @@ public class UserServiceTest extends AbstractServicesTest {
assertTrue(userService.getUserByUuid(user.getUuid()).getUuid().equals(user.getUuid()));
}
@Test(expected = UsernameNotFoundException.class)
@Test
public void getUserByUuidExceptionTest() {
userService.getUserByUuid(UUID.randomUUID().toString());
User user = userService.getUserByUuid(UUID.randomUUID().toString());
assertThat(user, nullValue());
}
@Test
......@@ -234,7 +237,8 @@ public class UserServiceTest extends AbstractServicesTest {
Set<UserRole> selectedRoles = Sets.newHashSet(UserRole.ADMINISTRATOR);
userService.setRoles(user, selectedRoles);
assertTrue(userService.getUserByEmail(email).getRoles().contains(UserRole.ADMINISTRATOR));
assertThat(userService.getUserByEmail(email).getRoles(), hasSize(2));
assertThat(userService.getUserByEmail(email).getRoles(), hasSize(3));
assertThat(userService.getUserByEmail(email).getRoles(), containsInAnyOrder(UserRole.USER, UserRole.ADMINISTRATOR, UserRole.EVERYONE));
}
@Test
......
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