Fixed test
This commit is contained in:
parent
861ddc0f4b
commit
4c9a294b1a
|
@ -7,7 +7,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.BadRequestException;
|
||||
import javax.ws.rs.ForbiddenException;
|
||||
import javax.ws.rs.core.MultivaluedHashMap;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
@ -18,6 +17,7 @@ import org.gcube.common.resources.gcore.Resources;
|
|||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.gcat.ContextTest;
|
||||
import org.gcube.gcat.api.GCatConstants;
|
||||
import org.gcube.gcat.utils.ContextUtility;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisher;
|
||||
import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
|
||||
import org.junit.Assert;
|
||||
|
@ -207,15 +207,16 @@ public class CKANPackageTest extends ContextTest {
|
|||
}
|
||||
|
||||
|
||||
@Test(expected=BadRequestException.class)
|
||||
@Test(expected=ForbiddenException.class)
|
||||
public void checkParameter() throws Exception {
|
||||
ContextTest.setContextByName("/gcube/devNext/NextNext");
|
||||
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
|
||||
CKANPackage ckanPackage = new CKANPackage();
|
||||
|
||||
MultivaluedMap<String,String> queryParameters = new MultivaluedHashMap<>();
|
||||
queryParameters.add(GCatConstants.Q_KEY, "organization:nextnext OR organization:devsec");
|
||||
queryParameters.add(GCatConstants.Q_KEY, "organization:nextnext OR organization:fakeorg");
|
||||
|
||||
parameters = ckanPackage.checkListParameters(queryParameters, parameters);
|
||||
|
||||
|
@ -268,6 +269,10 @@ public class CKANPackageTest extends ContextTest {
|
|||
|
||||
protected CKANPackage createPackage(ObjectMapper mapper) throws Exception {
|
||||
|
||||
String currentContext = ContextUtility.getCurrentContext();
|
||||
ScopeBean scopeBean = new ScopeBean(currentContext);
|
||||
String ckanOrganizationName = CKANPackage.getOrganizationName(scopeBean);
|
||||
|
||||
ObjectNode itemObjectNode = mapper.createObjectNode();
|
||||
itemObjectNode.put(CKAN.NAME_KEY, ITEM_NAME_VALUE);
|
||||
itemObjectNode.put(CKANPackage.TITLE_KEY, "RESTful Transaction Model");
|
||||
|
@ -275,21 +280,19 @@ public class CKANPackageTest extends ContextTest {
|
|||
itemObjectNode.put(PRIVATE_KEY, false);
|
||||
itemObjectNode.put(NOTES_KEY, "A research of Luca Frosini");
|
||||
itemObjectNode.put(URL_KEY, "http://www.d4science.org");
|
||||
// itemObjectNode.put(CKANPackage.OWNER_ORG_KEY, "devvre");
|
||||
itemObjectNode.put(CKANPackage.OWNER_ORG_KEY, ckanOrganizationName);
|
||||
|
||||
ArrayNode tagArrayNode = itemObjectNode.putArray(CKANPackage.TAGS_KEY);
|
||||
ObjectNode tagNode = mapper.createObjectNode();
|
||||
tagNode.put(CKANPackage.NAME_KEY, "REST");
|
||||
tagArrayNode.add(tagNode);
|
||||
|
||||
/*
|
||||
ArrayNode resourceArrayNode = itemObjectNode.putArray(CKANPackage.RESOURCES_KEY);
|
||||
ObjectNode resourceNode = mapper.createObjectNode();
|
||||
resourceNode.put(CKANResource.NAME_KEY, "RESTful Transaction Model");
|
||||
// Workspace(luca.frosini) > RESTful Transaction Model v 1.0.pdf
|
||||
resourceNode.put(CKANResource.URL_KEY, "https://goo.gl/J8AwQW");
|
||||
resourceArrayNode.add(resourceNode);
|
||||
*/
|
||||
|
||||
ArrayNode extraArrayNode = itemObjectNode.putArray(CKANPackage.EXTRAS_KEY);
|
||||
ObjectNode typeNode = mapper.createObjectNode();
|
||||
|
@ -334,6 +337,8 @@ public class CKANPackageTest extends ContextTest {
|
|||
|
||||
@Test
|
||||
public void createReadUpdateUpdatePurge() throws Exception {
|
||||
ContextTest.setContextByName("/gcube/devNext/NextNext");
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
createPackage(mapper);
|
||||
|
||||
|
@ -406,6 +411,7 @@ public class CKANPackageTest extends ContextTest {
|
|||
@Test
|
||||
//(expected = NotFoundException.class)
|
||||
public void delete() throws Exception {
|
||||
ContextTest.setContextByName("/gcube/devNext/NextNext");
|
||||
CKANPackage ckanPackage = new CKANPackage();
|
||||
ckanPackage.setName(ITEM_NAME_VALUE);
|
||||
ckanPackage.delete(true);
|
||||
|
|
Loading…
Reference in New Issue