Exposing AddToContext APi refs #5701
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@134114 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
631e030dae
commit
b40503fa33
|
@ -237,14 +237,14 @@ public class EntityManager {
|
|||
|
||||
|
||||
@POST
|
||||
@Path("add/" + EntityPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||
@Path(EntityPath.ADD_PATH_PART + "/" + EntityPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||
public boolean addResourceToContext(String uuid) throws ResourceNotFoundException,
|
||||
ContextNotFoundException, ResourceRegistryException {
|
||||
return entityManager.addResourceToContext(UUID.fromString(uuid));
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("add/" + EntityPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||
@Path(EntityPath.ADD_PATH_PART + "/" + EntityPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||
public boolean addFacetToContext(String uuid) throws FacetNotFoundException,
|
||||
ContextNotFoundException, ResourceRegistryException {
|
||||
return entityManager.addFacetToContext(UUID.fromString(uuid));
|
||||
|
|
|
@ -100,6 +100,11 @@ public class EntityManagementImplTest {
|
|||
logger.debug("Created : {}", json);
|
||||
eService = Entities.unmarshal(EService.class, json);
|
||||
logger.debug("Unmarshalled {} {}", EService.NAME, eService);
|
||||
|
||||
boolean deleted = entityManagementImpl.deleteResource(eService.getHeader().getUUID());
|
||||
Assert.assertTrue(deleted);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.ResourceNotFoundException;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -154,14 +155,35 @@ public class MultiContextTest {
|
|||
|
||||
|
||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||
entityManagementImpl.addResourceToContext(hostingNode.getHeader().getUUID());
|
||||
|
||||
UUID uuid = hostingNode.getHeader().getUUID();
|
||||
boolean addedToContext = entityManagementImpl.addResourceToContext(uuid);
|
||||
Assert.assertTrue(addedToContext);
|
||||
|
||||
|
||||
String hnString = entityManagementImpl.readResource(uuid);
|
||||
HostingNode readHN = Entities.unmarshal(HostingNode.class, hnString);
|
||||
Assert.assertTrue(readHN.getHeader().getUUID().compareTo(uuid)==0);
|
||||
|
||||
|
||||
UUID eServiceUUID = eService.getHeader().getUUID();
|
||||
try {
|
||||
entityManagementImpl.readResource(eServiceUUID);
|
||||
}catch(ResourceNotFoundException e){
|
||||
logger.debug("Resource with {} Not Found as Expected", uuid.toString());
|
||||
}
|
||||
|
||||
boolean deleted = entityManagementImpl.deleteResource(uuid);
|
||||
Assert.assertTrue(deleted);
|
||||
|
||||
deleted = entityManagementImpl.deleteResource(eService.getHeader().getUUID());
|
||||
Assert.assertTrue(deleted);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
public void addTest() throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException{
|
||||
ScopeProvider.instance.set("/gcube/devNext/NextNext");
|
||||
entityManagementImpl.addResourceToContext(UUID.fromString("75583599-c082-4b89-84ab-125e64d768c4"));
|
||||
entityManagementImpl.addResourceToContext(UUID.fromString(""));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue