Added tests for the convenient method introduced Resource in IS model

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@146678 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-04-06 18:21:11 +00:00
parent 8a985b16f3
commit 20359dd47b
2 changed files with 37 additions and 1 deletions

View File

@ -319,7 +319,7 @@ public class ERManagementTest extends ScopedTest {
isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode,
networkingFacet, null);
hostingNode.attachFacet(isIdentifiedBy);
hostingNode.addFacet(isIdentifiedBy);
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();

View File

@ -238,6 +238,42 @@ public class SmartgearResourcesTest extends ScopedTest {
HostingNode hostingNodeToUpdate = ISMapper.unmarshal(HostingNode.class,
json);
/* Testing convenient methods */
@SuppressWarnings("unchecked")
List<ConsistsOf<? extends Resource, ? extends Facet>> hasVolatileMemoryList = hostingNodeToUpdate.getConsistsOf(HasVolatileMemory.class);
Assert.assertTrue(hasVolatileMemoryList.size()==2);
@SuppressWarnings("unchecked")
List<ConsistsOf<? extends Resource, ? extends Facet>> hasPeristentMemoryList = hostingNodeToUpdate.getConsistsOf(HasPersistentMemory.class);
Assert.assertTrue(hasPeristentMemoryList.size()==1);
@SuppressWarnings("unchecked")
List<ConsistsOf<? extends Resource, MemoryFacet>> memoryList = hostingNodeToUpdate.getConsistsOf(ConsistsOf.class, MemoryFacet.class);
Assert.assertTrue(memoryList.size()==3);
List<ContainerStateFacet> csfList = hostingNodeToUpdate.getFacets(ContainerStateFacet.class);
Assert.assertTrue(csfList.size()==1);
List<SimplePropertyFacet> spfList = hostingNodeToUpdate.getFacets(SimplePropertyFacet.class);
Assert.assertTrue(spfList.size()==1);
List<SoftwareFacet> sfList = hostingNodeToUpdate.getFacets(SoftwareFacet.class);
Assert.assertTrue(sfList.size()==1);
List<CPUFacet> cfList = hostingNodeToUpdate.getFacets(CPUFacet.class);
Assert.assertTrue(cfList.size()==4);
List<NetworkingFacet> nfList = hostingNodeToUpdate.getFacets(NetworkingFacet.class);
Assert.assertTrue(nfList.size()==1);
@SuppressWarnings("unchecked")
List<IsIdentifiedBy<? extends Resource, MemoryFacet>> isbnfList = hostingNodeToUpdate.getConsistsOf(IsIdentifiedBy.class, NetworkingFacet.class);
Assert.assertTrue(isbnfList.size()==1);
/* Testing convenient methods */
List<ConsistsOf<? extends Resource, ? extends Facet>> consistsOfToRemove = new ArrayList<>();
List<ConsistsOf<? extends Resource, ? extends Facet>> consistsOfList = hostingNodeToUpdate