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