[DS-3952] Fix a broken test. Various cleanups.

This commit is contained in:
Mark H. Wood
2021-08-08 19:12:49 -04:00
parent 596df53d0a
commit c427a2e83f
5 changed files with 9 additions and 61 deletions

View File

@@ -77,7 +77,7 @@ public class AbstractDSpaceTest {
//load the properties of the tests
testProps = new Properties();
URL properties = AbstractUnitTest.class.getClassLoader()
URL properties = AbstractDSpaceTest.class.getClassLoader()
.getResource("test-config.properties");
testProps.load(properties.openStream());

View File

@@ -14,8 +14,6 @@ import java.util.UUID;
import javax.servlet.http.HttpServletRequest;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dspace.app.requestitem.RequestItem;
import org.dspace.app.requestitem.service.RequestItemService;
import org.dspace.app.rest.converter.RequestItemConverter;
@@ -42,8 +40,6 @@ import org.springframework.stereotype.Component;
@Component(RequestItemRest.CATEGORY + '.' + RequestItemRest.NAME)
public class RequestItemRepository
extends DSpaceRestRepository<RequestItemRest, String> {
private static final Logger LOG = LogManager.getLogger();
@Autowired(required = true)
protected RequestItemService requestItemService;
@@ -57,6 +53,7 @@ public class RequestItemRepository
protected RequestItemConverter requestItemConverter;
@Override
//@PreAuthorize(expr)
public RequestItemRest findOne(Context context, String id) {
RequestItem requestItem = requestItemService.findByToken(context, id);
if (null == requestItem) {

View File

@@ -5,7 +5,7 @@
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest.repository;
package org.dspace.app.rest;
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
import static org.hamcrest.Matchers.is;
@@ -30,6 +30,7 @@ import org.dspace.app.requestitem.service.RequestItemService;
import org.dspace.app.rest.converter.RequestItemConverter;
import org.dspace.app.rest.matcher.RequestCopyMatcher;
import org.dspace.app.rest.model.RequestItemRest;
import org.dspace.app.rest.repository.RequestItemRepository;
import org.dspace.app.rest.test.AbstractControllerIntegrationTest;
import org.dspace.authorize.AuthorizeException;
import org.dspace.builder.BitstreamBuilder;
@@ -156,11 +157,11 @@ public class RequestItemRepositoryIT
hasJsonPath("$.id", not(isEmptyOrNullString())),
hasJsonPath("$.type", is(RequestItemRest.NAME)),
hasJsonPath("$.token", not(isEmptyOrNullString())),
hasJsonPath("$.request_email", is(RequestItemBuilder.REQ_EMAIL)),
hasJsonPath("$.request_message", is(RequestItemBuilder.REQ_MESSAGE)),
hasJsonPath("$.request_name", is(RequestItemBuilder.REQ_NAME)),
hasJsonPath("$.requestEmail", is(RequestItemBuilder.REQ_EMAIL)),
hasJsonPath("$.requestMessage", is(RequestItemBuilder.REQ_MESSAGE)),
hasJsonPath("$.requestName", is(RequestItemBuilder.REQ_NAME)),
hasJsonPath("$.allfiles", is(false)),
hasJsonPath("$.request_date", not(isEmptyOrNullString())), // TODO should be an ISO datetime
hasJsonPath("$.requestDate", not(isEmptyOrNullString())), // TODO should be an ISO datetime
hasJsonPath("$._links.self.href", not(isEmptyOrNullString()))
)))
.andReturn();

View File

@@ -1,50 +0,0 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.app.rest;
import static org.junit.Assert.assertEquals;
import org.dspace.app.rest.model.RequestItemRest;
import org.dspace.app.rest.repository.RequestItemRepository;
import org.junit.Test;
/**
*
* @author Mark H. Wood <mwood@iupui.edu>
*/
public class RequestItemRepositoryTest {
/**
* Test of getDomainClass method, of class RequestItemRepository.
*/
@Test
public void testGetDomainClass() {
System.out.println("getDomainClass");
RequestItemRepository instance = new RequestItemRepository();
Class instanceClass = instance.getDomainClass();
assertEquals("Wrong domain class", RequestItemRest.class, instanceClass);
}
/**
* Test of wrapResource method, of class RequestItemRepository.
*/
/*
@Test
public void testWrapResource() {
System.out.println("wrapResource");
RequestItemRest model = null;
String[] rels = null;
RequestItemRepository instance = new RequestItemRepository();
RequestItemResource expResult = null;
RequestItemResource result = instance.wrapResource(model, rels);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
*/
}

View File

@@ -15,7 +15,7 @@ import static org.hamcrest.Matchers.is;
import org.dspace.app.requestitem.RequestItem;
import org.dspace.app.rest.model.RequestItemRest;
import org.dspace.app.rest.repository.RequestItemRepositoryIT;
import org.dspace.app.rest.RequestItemRepositoryIT;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;