Reorganizing tests
This commit is contained in:
parent
23d0486f64
commit
5801089325
|
@ -21,7 +21,7 @@ import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSec
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.SecurityType;
|
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.SecurityType;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entity.FacetManagementTest;
|
import org.gcube.informationsystem.resourceregistry.tobereviewed.FacetManagementTest;
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
import org.gcube.informationsystem.utils.ElementMapper;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
|
@ -21,6 +21,7 @@ import org.gcube.informationsystem.resourceregistry.api.utils.Utility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.tobereviewed.FacetManagementTest;
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
import org.gcube.informationsystem.utils.ElementMapper;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.facets.AccessPointFacetImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl;
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.ERManagementUtility;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
|
||||||
import org.gcube.informationsystem.utils.ElementMapper;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.resources.EService;
|
|
||||||
import org.gcube.resourcemanagement.model.reference.relations.consistsof.IsIdentifiedBy;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
|
||||||
*/
|
|
||||||
public class AnotherEnhancedTest extends MultiContextTest {
|
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory
|
|
||||||
.getLogger(AnotherEnhancedTest.class);
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNoFollows() throws Exception {
|
|
||||||
ContextTest.setContextByName(DEFAULT_TEST_SCOPE);
|
|
||||||
|
|
||||||
EService eService = ERManagementTest.instantiateValidEService();
|
|
||||||
|
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
|
||||||
resourceManagement.setElementType(EService.NAME);
|
|
||||||
resourceManagement.setJson(ElementMapper.marshal(eService));
|
|
||||||
|
|
||||||
String json = resourceManagement.create();
|
|
||||||
logger.debug("Created : {}", json);
|
|
||||||
eService = ElementMapper.unmarshal(EService.class, json);
|
|
||||||
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
|
||||||
|
|
||||||
JsonNode jsonNode = ElementMapper.getObjectMapper().readTree(json);
|
|
||||||
|
|
||||||
Map<UUID, JsonNode> expectedInstances = new HashMap<>();
|
|
||||||
expectedInstances.put(eService.getHeader().getUUID(), jsonNode);
|
|
||||||
|
|
||||||
UUID contextUUID = ContextUtility.getInstance().getSecurityContextByFullName(ALTERNATIVE_TEST_SCOPE).getUUID();
|
|
||||||
|
|
||||||
try {
|
|
||||||
ERManagementUtility.addToContextNoPropagationConstraint(expectedInstances, contextUUID, true);
|
|
||||||
}catch (ResourceRegistryException e) {
|
|
||||||
logger.debug("As expected {}", e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
IsIdentifiedBy<EService, Facet> gotIsIdentifiedBy = (IsIdentifiedBy<EService, Facet>) eService.getConsistsOf(IsIdentifiedBy.class).get(0);
|
|
||||||
|
|
||||||
JsonNode gotIsIdentifiedByJsonNode = ElementMapper.getObjectMapper().readTree(ElementMapper.marshal(gotIsIdentifiedBy));
|
|
||||||
expectedInstances.put(gotIsIdentifiedBy.getHeader().getUUID(), gotIsIdentifiedByJsonNode);
|
|
||||||
|
|
||||||
try {
|
|
||||||
ERManagementUtility.addToContextNoPropagationConstraint(expectedInstances, contextUUID, true);
|
|
||||||
}catch (ResourceRegistryException e) {
|
|
||||||
// as expected
|
|
||||||
logger.debug("As expected {}", e.getMessage());
|
|
||||||
}finally {
|
|
||||||
resourceManagement.delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -3,7 +3,6 @@ package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAlreadyPresentException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAlreadyPresentException;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.informationsystem.resourceregistry.tobereviewed;
|
||||||
|
|
||||||
|
import org.gcube.informationsystem.resourceregistry.instances.multicontext.MultiContextTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*/
|
||||||
|
public class AnotherEnhancedTest extends MultiContextTest {
|
||||||
|
|
||||||
|
// private static Logger logger = LoggerFactory
|
||||||
|
// .getLogger(AnotherEnhancedTest.class);
|
||||||
|
//
|
||||||
|
// @Test
|
||||||
|
// public void testNoFollows() throws Exception {
|
||||||
|
// ContextTest.setContextByName(DEFAULT_TEST_SCOPE);
|
||||||
|
//
|
||||||
|
// EService eService = ERManagementTest.instantiateValidEService();
|
||||||
|
//
|
||||||
|
// ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
|
// resourceManagement.setElementType(EService.NAME);
|
||||||
|
// resourceManagement.setJson(ElementMapper.marshal(eService));
|
||||||
|
//
|
||||||
|
// String json = resourceManagement.create();
|
||||||
|
// logger.debug("Created : {}", json);
|
||||||
|
// eService = ElementMapper.unmarshal(EService.class, json);
|
||||||
|
// logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
||||||
|
//
|
||||||
|
// JsonNode jsonNode = ElementMapper.getObjectMapper().readTree(json);
|
||||||
|
//
|
||||||
|
// Map<UUID, JsonNode> expectedInstances = new HashMap<>();
|
||||||
|
// expectedInstances.put(eService.getHeader().getUUID(), jsonNode);
|
||||||
|
//
|
||||||
|
// UUID contextUUID = ContextUtility.getInstance().getSecurityContextByFullName(ALTERNATIVE_TEST_SCOPE).getUUID();
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// ERManagementUtility.addToContextNoPropagationConstraint(expectedInstances, contextUUID, true);
|
||||||
|
// }catch (ResourceRegistryException e) {
|
||||||
|
// logger.debug("As expected {}", e.getMessage());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @SuppressWarnings("unchecked")
|
||||||
|
// IsIdentifiedBy<EService, Facet> gotIsIdentifiedBy = (IsIdentifiedBy<EService, Facet>) eService.getConsistsOf(IsIdentifiedBy.class).get(0);
|
||||||
|
//
|
||||||
|
// JsonNode gotIsIdentifiedByJsonNode = ElementMapper.getObjectMapper().readTree(ElementMapper.marshal(gotIsIdentifiedBy));
|
||||||
|
// expectedInstances.put(gotIsIdentifiedBy.getHeader().getUUID(), gotIsIdentifiedByJsonNode);
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
// ERManagementUtility.addToContextNoPropagationConstraint(expectedInstances, contextUUID, true);
|
||||||
|
// }catch (ResourceRegistryException e) {
|
||||||
|
// // as expected
|
||||||
|
// logger.debug("As expected {}", e.getMessage());
|
||||||
|
// }finally {
|
||||||
|
// resourceManagement.delete();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.instances.model.entity;
|
package org.gcube.informationsystem.resourceregistry.tobereviewed;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
Loading…
Reference in New Issue