Fixed test

This commit is contained in:
Luca Frosini 2019-07-30 16:48:39 +02:00
parent a646b11fca
commit bb5d264248
1 changed files with 17 additions and 70 deletions

View File

@ -36,12 +36,12 @@ public class Serializer {
private static Logger logger = LoggerFactory.getLogger(Serializer.class);
@Test
public void serializeAccessPoint() throws Exception{
public void serializeAccessPoint() throws Exception {
logger.trace(TypeBinder.serializeType(AccessPointFacet.class));
}
@Test
public void serializeFacet() throws JsonGenerationException, JsonMappingException, IOException{
public void serializeFacet() throws JsonGenerationException, JsonMappingException, IOException {
CPUFacetImpl cpuFacetImpl = new CPUFacetImpl();
cpuFacetImpl.setClockSpeed("1 GHz");
cpuFacetImpl.setModel("Opteron");
@ -92,12 +92,12 @@ public class Serializer {
logger.debug(ISMapper.marshal(list));
Facet[] array = new Facet[]{cpuFacetImpl, cpuFacet, contactFacet};
Facet[] array = new Facet[] {cpuFacetImpl, cpuFacet, contactFacet};
logger.debug(ISMapper.marshal(array));
}
@Test
public void serializeDeserializeResource() throws JsonGenerationException, JsonMappingException, IOException{
public void serializeDeserializeResource() throws JsonGenerationException, JsonMappingException, IOException {
HostingNode hostingNode = new HostingNodeImpl();
CPUFacet cpuFacet = new CPUFacetImpl();
@ -126,7 +126,7 @@ public class Serializer {
}
@Test
public void serializeRelation() throws JsonGenerationException, JsonMappingException, IOException{
public void serializeRelation() throws JsonGenerationException, JsonMappingException, IOException {
HostingNode hostingNode = new HostingNodeImpl();
CPUFacet cpuFacet = new CPUFacetImpl();
@ -134,48 +134,23 @@ public class Serializer {
cpuFacet.setModel("Opteron");
cpuFacet.setVendor("AMD");
ConsistsOf<Resource, Facet> consistsOf = new ConsistsOfImpl<Resource, Facet>(hostingNode, cpuFacet, null);
ConsistsOf<Resource,Facet> consistsOf = new ConsistsOfImpl<Resource,Facet>(hostingNode, cpuFacet, null);
StringWriter stringWriter = new StringWriter();
ISMapper.marshal(consistsOf, stringWriter);
logger.trace(stringWriter.toString());
}
@Test
public void deserializeResource() throws JsonGenerationException, JsonMappingException, IOException{
StringReader stringReader = new StringReader(
"{"
+ "\"@class\":\"HostingNode\","
+ "\"header\":null,"
+ "\"consistsOf\":[{"
+ "\"@class\":\"ConsistsOf\","
+ "\"header\":null,"
+ "\"target\":{"
+ "\"@class\":\"CPUFacet\","
+ "\"header\":null,"
+ "\"model\":\"Opteron\","
+ "\"vendor\":\"AMD\","
+ "\"clockSpeed\":\"1 GHz\""
+ "},"
+ "\"relationProperty\":null"
+ "},"
+ "{"
+ "\"@class\":\"ConsistsOf\","
+ "\"header\":null,"
+ "\"target\":{"
+ "\"@class\":\"ContactFacet\","
+ "\"header\":null,"
+ "\"title\":null,"
+ "\"name\":\"Luca\","
+ "\"middleName\":null,"
+ "\"surname\":\"Frosini\","
+ "\"eMail\":\"luca.frosini@isti.cnr.it\""
+ "},"
+ "\"relationProperty\":null"
+ "}"
+ "],"
+ "\"isRelatedTo\":[]"
+ "}");
public void deserializeResource() throws JsonGenerationException, JsonMappingException, IOException {
StringReader stringReader = new StringReader("{" + "\"@class\":\"HostingNode\"," + "\"header\":null,"
+ "\"consistsOf\":[{" + "\"@class\":\"ConsistsOf\"," + "\"header\":null," + "\"target\":{"
+ "\"@class\":\"CPUFacet\"," + "\"header\":null," + "\"model\":\"Opteron\"," + "\"vendor\":\"AMD\","
+ "\"clockSpeed\":\"1 GHz\"" + "}," + "\"relationProperty\":null" + "}," + "{"
+ "\"@class\":\"ConsistsOf\"," + "\"header\":null," + "\"target\":{" + "\"@class\":\"ContactFacet\","
+ "\"header\":null," + "\"title\":null," + "\"name\":\"Luca\"," + "\"middleName\":null,"
+ "\"surname\":\"Frosini\"," + "\"eMail\":\"luca.frosini@isti.cnr.it\"" + "},"
+ "\"relationProperty\":null" + "}" + "]," + "\"isRelatedTo\":[]" + "}");
HostingNode hn = ISMapper.unmarshal(HostingNode.class, stringReader);
@ -185,35 +160,7 @@ public class Serializer {
@Test
public void deserializeContext() throws JsonParseException, JsonMappingException, IOException {
String contextString = "{" +
"\"@type\": \"d\"," +
"\"@rid\": \"#33:0\"," +
"\"@version\": 3," +
"\"@class\": \"Context\"," +
"\"name\": \"gcube\"," +
"\"header\": {" +
"\"@type\": \"d\"," +
"\"@version\": 0," +
"\"@class\": \"Header\"," +
"\"uuid\": \"50d9e8ab-71f5-43cc-afa0-61cdef161d04\"," +
"\"creator\": \"UNKNOWN_USER\"," +
"\"creationTime\": \"2016-09-07 11:45:17\"," +
"\"lastUpdateTime\": \"2016-09-07 11:45:18\"," +
"\"@fieldTypes\": \"creationTime=t,lastUpdateTime=t\"" +
"}," +
"\"_allow\": [" +
"\"#5:0\"," +
"\"#4:5\"" +
"]," +
"\"_allowRead\": [" +
"\"#4:6\"" +
"]," +
"\"out_IsParentOf\": [" +
"\"#260:0\"," +
"\"#262:0\"" +
"]," +
"\"@fieldTypes\": \"_allow=n,_allowRead=n,out_IsParentOf=g\"" +
"}";
String contextString = "{\"name\":\"gcube\",\"header\":{\"@class\":\"Header\",\"creator\":\"UNKNOWN_USER\",\"creationTime\":\"2019-02-06 11:08:33.706 +0100\",\"modifiedBy\":\"UNKNOWN_USER\",\"uuid\":\"fe44822a-d8bb-418b-ba79-59b4aef01cf9\",\"lastUpdateTime\":\"2019-02-06 11:08:33.706 +0100\"},\"@class\":\"Context\",\"@superClasses\":[\"Entity\"],\"children\":[{\"header\":{\"@class\":\"Header\",\"creator\":\"UNKNOWN_USER\",\"creationTime\":\"2019-02-06 11:08:34.627 +0100\",\"modifiedBy\":\"UNKNOWN_USER\",\"uuid\":\"401a2381-3a05-48fd-952b-0aa3cbb8ad8b\",\"lastUpdateTime\":\"2019-02-06 11:08:34.627 +0100\"},\"propagationConstraint\":{\"@class\":\"PropagationConstraint\",\"add\":\"unpropagate\",\"remove\":\"keep\"},\"@class\":\"IsParentOf\",\"@superClasses\":[\"Relation\"],\"target\":{\"name\":\"devsec\",\"header\":{\"@class\":\"Header\",\"creator\":\"UNKNOWN_USER\",\"creationTime\":\"2019-02-06 11:08:34.663 +0100\",\"modifiedBy\":\"UNKNOWN_USER\",\"uuid\":\"007f9154-25fa-4f52-9cd4-ec1f8c3c3baf\",\"lastUpdateTime\":\"2019-02-06 11:08:34.663 +0100\"},\"@class\":\"Context\",\"@superClasses\":[\"Entity\"]}},{\"header\":{\"@class\":\"Header\",\"creator\":\"UNKNOWN_USER\",\"creationTime\":\"2019-02-06 11:08:36.658 +0100\",\"modifiedBy\":\"UNKNOWN_USER\",\"uuid\":\"aeec2ea9-c3d2-43af-998e-d19953fc2c42\",\"lastUpdateTime\":\"2019-02-06 11:08:36.658 +0100\"},\"propagationConstraint\":{\"@class\":\"PropagationConstraint\",\"add\":\"unpropagate\",\"remove\":\"keep\"},\"@class\":\"IsParentOf\",\"@superClasses\":[\"Relation\"],\"target\":{\"name\":\"devNext\",\"header\":{\"@class\":\"Header\",\"creator\":\"UNKNOWN_USER\",\"creationTime\":\"2019-02-06 11:08:36.695 +0100\",\"modifiedBy\":\"UNKNOWN_USER\",\"uuid\":\"b16bc587-3fd8-4c0a-9196-8515c4501649\",\"lastUpdateTime\":\"2019-02-06 11:08:36.695 +0100\"},\"@class\":\"Context\",\"@superClasses\":[\"Entity\"]}},{\"header\":{\"@class\":\"Header\",\"creator\":\"UNKNOWN_USER\",\"creationTime\":\"2019-02-06 11:08:38.224 +0100\",\"modifiedBy\":\"UNKNOWN_USER\",\"uuid\":\"eba6cd76-525c-4037-9095-a712b054fd1b\",\"lastUpdateTime\":\"2019-02-06 11:08:38.224 +0100\"},\"propagationConstraint\":{\"@class\":\"PropagationConstraint\",\"add\":\"unpropagate\",\"remove\":\"keep\"},\"@class\":\"IsParentOf\",\"@superClasses\":[\"Relation\"],\"target\":{\"name\":\"preprod\",\"header\":{\"@class\":\"Header\",\"creator\":\"UNKNOWN_USER\",\"creationTime\":\"2019-02-06 11:08:38.248 +0100\",\"modifiedBy\":\"UNKNOWN_USER\",\"uuid\":\"d971a5e4-0a11-49c6-a65d-551161802335\",\"lastUpdateTime\":\"2019-02-06 11:08:38.248 +0100\"},\"@class\":\"Context\",\"@superClasses\":[\"Entity\"]}}]}";
StringReader stringReader = new StringReader(contextString);
Context c = ISMapper.unmarshal(Context.class, stringReader);