Added test checks

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@146399 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-03-28 14:27:56 +00:00
parent c6fb345a3b
commit f8ce50d91d
1 changed files with 32 additions and 0 deletions

View File

@ -19,7 +19,9 @@ import org.gcube.informationsystem.impl.entity.facet.EventFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.LicenseFacetImpl; import org.gcube.informationsystem.impl.entity.facet.LicenseFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.NetworkingFacetImpl; import org.gcube.informationsystem.impl.entity.facet.NetworkingFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.ServiceStateFacetImpl; import org.gcube.informationsystem.impl.entity.facet.ServiceStateFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.SimpleFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.SoftwareFacetImpl; import org.gcube.informationsystem.impl.entity.facet.SoftwareFacetImpl;
import org.gcube.informationsystem.impl.entity.facet.StateFacetImpl;
import org.gcube.informationsystem.impl.entity.resource.EServiceImpl; import org.gcube.informationsystem.impl.entity.resource.EServiceImpl;
import org.gcube.informationsystem.impl.entity.resource.HostingNodeImpl; import org.gcube.informationsystem.impl.entity.resource.HostingNodeImpl;
import org.gcube.informationsystem.impl.relation.IsIdentifiedByImpl; import org.gcube.informationsystem.impl.relation.IsIdentifiedByImpl;
@ -32,11 +34,14 @@ import org.gcube.informationsystem.model.entity.Facet;
import org.gcube.informationsystem.model.entity.Resource; import org.gcube.informationsystem.model.entity.Resource;
import org.gcube.informationsystem.model.entity.facet.AccessPointFacet; import org.gcube.informationsystem.model.entity.facet.AccessPointFacet;
import org.gcube.informationsystem.model.entity.facet.CPUFacet; import org.gcube.informationsystem.model.entity.facet.CPUFacet;
import org.gcube.informationsystem.model.entity.facet.ContactFacet;
import org.gcube.informationsystem.model.entity.facet.EventFacet; import org.gcube.informationsystem.model.entity.facet.EventFacet;
import org.gcube.informationsystem.model.entity.facet.LicenseFacet; import org.gcube.informationsystem.model.entity.facet.LicenseFacet;
import org.gcube.informationsystem.model.entity.facet.NetworkingFacet; import org.gcube.informationsystem.model.entity.facet.NetworkingFacet;
import org.gcube.informationsystem.model.entity.facet.ServiceStateFacet; import org.gcube.informationsystem.model.entity.facet.ServiceStateFacet;
import org.gcube.informationsystem.model.entity.facet.SimpleFacet;
import org.gcube.informationsystem.model.entity.facet.SoftwareFacet; import org.gcube.informationsystem.model.entity.facet.SoftwareFacet;
import org.gcube.informationsystem.model.entity.facet.StateFacet;
import org.gcube.informationsystem.model.entity.resource.EService; import org.gcube.informationsystem.model.entity.resource.EService;
import org.gcube.informationsystem.model.entity.resource.HostingNode; import org.gcube.informationsystem.model.entity.resource.HostingNode;
import org.gcube.informationsystem.model.relation.ConsistsOf; import org.gcube.informationsystem.model.relation.ConsistsOf;
@ -45,6 +50,7 @@ import org.gcube.informationsystem.model.relation.IsRelatedTo;
import org.gcube.informationsystem.model.relation.Relation; import org.gcube.informationsystem.model.relation.Relation;
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts; import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
import org.gcube.informationsystem.resourceregistry.ScopedTest; import org.gcube.informationsystem.resourceregistry.ScopedTest;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
import org.gcube.informationsystem.resourceregistry.er.entity.FacetManagement; import org.gcube.informationsystem.resourceregistry.er.entity.FacetManagement;
import org.gcube.informationsystem.resourceregistry.er.entity.ResourceManagement; import org.gcube.informationsystem.resourceregistry.er.entity.ResourceManagement;
@ -126,6 +132,32 @@ public class ERManagementTest extends ScopedTest {
} }
@Test(expected=ResourceRegistryException.class)
public void testCreateAbstarctEntity() throws Exception {
StateFacet stateFacet = new StateFacetImpl();
stateFacet.setValue("READY");
FacetManagement facetManagement = new FacetManagement();
facetManagement.setElementType(StateFacet.NAME);
String json = ISMapper.marshal(stateFacet);
logger.debug(json);
facetManagement.setJSON(json);
facetManagement.create();
}
@Test(expected=ResourceRegistryException.class)
public void testCreateAnEntityDifferentFromDeclared() throws Exception {
SimpleFacet simpleFacet = new SimpleFacetImpl();
FacetManagement facetManagement = new FacetManagement();
facetManagement.setElementType(ContactFacet.NAME);
facetManagement.setJSON(ISMapper.marshal(simpleFacet));
facetManagement.create();
}
@Test @Test
public void testCreateReadDeleteFacet() throws Exception { public void testCreateReadDeleteFacet() throws Exception {
CPUFacet cpuFacet = new CPUFacetImpl(); CPUFacet cpuFacet = new CPUFacetImpl();