Loading src/main/java/net/ivoa/xml/vospace/v2/Transfer.java +8 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; Loading Loading @@ -82,9 +83,12 @@ import javax.xml.bind.annotation.XmlType; // </edit> public class Transfer { @XmlElements({ @XmlElement(required = true) }) @XmlSchemaType(name = "anyURI") protected String target; private List<String> target; protected String direction; protected View view; @XmlElement(name = "protocol") Loading @@ -106,7 +110,7 @@ public class Transfer { * {@link String } * */ public String getTarget() { public List<String> getTarget() { return target; } Loading @@ -118,7 +122,7 @@ public class Transfer { * {@link String } * */ public void setTarget(String value) { public void setTarget(List<String> value) { this.target = value; } Loading src/test/java/net/ivoa/xml/uws/v1/JobSummaryTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ package net.ivoa.xml.uws.v1; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.StringReader; import java.io.StringWriter; import java.util.Arrays; import javax.xml.bind.JAXB; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; Loading Loading @@ -62,7 +63,7 @@ public class JobSummaryTest { */ @Test public void testDeserializeTransferServiceResponse() throws Exception { String response = "{\"jobId\": \"917c784f814c4a1a91a9d5d1af07dbe9\", \"ownerId\": \"2386\", \"jobType\": \"pullToVoSpace\", \"phase\": \"PENDING\", \"startTime\": null, \"endTime\": null, \"creationTime\": \"2021-02-03T15:05:57.233602\", \"jobInfo\": {\"transfer\": {\"view\": null, \"target\": \"vos://example.com!vospace/szorba/aaa\", \"version\": null, \"direction\": \"pullToVoSpace\", \"keepBytes\": null, \"protocols\": [{\"uri\": \"ia2:async-recall\", \"param\": [{\"uri\": \"ia2:node-type\", \"value\": \"single\"}], \"endpoint\": null}]}}, \"results\": null}"; String response = "{\"jobId\": \"917c784f814c4a1a91a9d5d1af07dbe9\", \"ownerId\": \"2386\", \"jobType\": \"pullToVoSpace\", \"phase\": \"PENDING\", \"startTime\": null, \"endTime\": null, \"creationTime\": \"2021-02-03T15:05:57.233602\", \"jobInfo\": {\"transfer\": {\"view\": null, \"target\": [\"vos://example.com!vospace/szorba/aaa\"], \"version\": null, \"direction\": \"pullToVoSpace\", \"keepBytes\": null, \"protocols\": [{\"uri\": \"ia2:async-recall\", \"endpoint\": null}]}}, \"results\": null}"; MAPPER.readValue(response, JobSummary.class); } Loading @@ -77,7 +78,7 @@ public class JobSummaryTest { Transfer transfer = new Transfer(); transfer.setVersion("2.1"); transfer.setTarget("vos://example.com!vospace/mydata1"); transfer.setTarget(Arrays.asList("vos://example.com!vospace/mydata1")); transfer.setDirection("pullFromVoSpace"); Protocol protocol1 = new Protocol(); protocol1.setUri("ivo://ivoa.net/vospace/core#httpget"); Loading Loading @@ -109,7 +110,7 @@ public class JobSummaryTest { Transfer transfer = (Transfer) deserializedJob.getJobInfo().getAny().get(0); assertEquals("2.1", transfer.getVersion()); assertEquals("pullFromVoSpace", transfer.getDirection()); assertEquals("vos://example.com!vospace/mydata1", transfer.getTarget()); assertArrayEquals(new String[]{"vos://example.com!vospace/mydata1"}, transfer.getTarget().toArray(String[]::new)); Protocol protocol = transfer.getProtocols().get(0); assertEquals("ivo://ivoa.net/vospace/core#httpget", protocol.getUri()); Loading src/test/java/net/ivoa/xml/vospace/v2/TransferTest.java +27 −9 Original line number Diff line number Diff line Loading @@ -9,8 +9,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import it.inaf.oats.vospace.datamodel.NodeProperties; import java.io.StringReader; import java.io.StringWriter; import java.util.Arrays; import javax.xml.bind.JAXB; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; public class TransferTest { Loading @@ -20,15 +23,31 @@ public class TransferTest { private static final String URI_PREFIX = "vos://example.com!vospace"; @Test public void testXmlSerialization() throws Exception { public void testSingleTarget() throws Exception { Transfer transfer = getTransfer(); Transfer transfer = getBaseTransfer(); transfer.setTarget(Arrays.asList(URI_PREFIX + "/mynode")); testXmlSerialization(transfer); } @Test public void testMultipleTargets() throws Exception { Transfer transfer = getBaseTransfer(); transfer.setTarget(Arrays.asList(URI_PREFIX + "/mynode1", URI_PREFIX + "/mynode2")); testXmlSerialization(transfer); } private void testXmlSerialization(Transfer transfer) throws Exception { String xml; try ( StringWriter sw = new StringWriter()) { JAXB.marshal(transfer, sw); xml = sw.toString(); System.out.println(xml); assertTrue(xml.contains("<vos:transfer")); } Transfer deserialized; Loading @@ -39,10 +58,9 @@ public class TransferTest { verifyTransfersAreEquals(transfer, deserialized); } private Transfer getTransfer() { Transfer transfer = new Transfer(); private Transfer getBaseTransfer() { transfer.setTarget(URI_PREFIX + "/mynode"); Transfer transfer = new Transfer(); transfer.setDirection("pullFromVoSpace"); Protocol protocol = new Protocol(); Loading @@ -62,7 +80,7 @@ public class TransferTest { private void verifyTransfersAreEquals(Transfer serialized, Transfer deserialized) { assertEquals(serialized.getTarget(), deserialized.getTarget()); assertArrayEquals(serialized.getTarget().toArray(String[]::new), deserialized.getTarget().toArray(String[]::new)); assertEquals(serialized.getDirection(), deserialized.getDirection()); assertEquals(serialized.getProtocols().size(), deserialized.getProtocols().size()); assertEquals(serialized.getParam().size(), deserialized.getParam().size()); Loading Loading
src/main/java/net/ivoa/xml/vospace/v2/Transfer.java +8 −4 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; Loading Loading @@ -82,9 +83,12 @@ import javax.xml.bind.annotation.XmlType; // </edit> public class Transfer { @XmlElements({ @XmlElement(required = true) }) @XmlSchemaType(name = "anyURI") protected String target; private List<String> target; protected String direction; protected View view; @XmlElement(name = "protocol") Loading @@ -106,7 +110,7 @@ public class Transfer { * {@link String } * */ public String getTarget() { public List<String> getTarget() { return target; } Loading @@ -118,7 +122,7 @@ public class Transfer { * {@link String } * */ public void setTarget(String value) { public void setTarget(List<String> value) { this.target = value; } Loading
src/test/java/net/ivoa/xml/uws/v1/JobSummaryTest.java +4 −3 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ package net.ivoa.xml.uws.v1; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.StringReader; import java.io.StringWriter; import java.util.Arrays; import javax.xml.bind.JAXB; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; Loading Loading @@ -62,7 +63,7 @@ public class JobSummaryTest { */ @Test public void testDeserializeTransferServiceResponse() throws Exception { String response = "{\"jobId\": \"917c784f814c4a1a91a9d5d1af07dbe9\", \"ownerId\": \"2386\", \"jobType\": \"pullToVoSpace\", \"phase\": \"PENDING\", \"startTime\": null, \"endTime\": null, \"creationTime\": \"2021-02-03T15:05:57.233602\", \"jobInfo\": {\"transfer\": {\"view\": null, \"target\": \"vos://example.com!vospace/szorba/aaa\", \"version\": null, \"direction\": \"pullToVoSpace\", \"keepBytes\": null, \"protocols\": [{\"uri\": \"ia2:async-recall\", \"param\": [{\"uri\": \"ia2:node-type\", \"value\": \"single\"}], \"endpoint\": null}]}}, \"results\": null}"; String response = "{\"jobId\": \"917c784f814c4a1a91a9d5d1af07dbe9\", \"ownerId\": \"2386\", \"jobType\": \"pullToVoSpace\", \"phase\": \"PENDING\", \"startTime\": null, \"endTime\": null, \"creationTime\": \"2021-02-03T15:05:57.233602\", \"jobInfo\": {\"transfer\": {\"view\": null, \"target\": [\"vos://example.com!vospace/szorba/aaa\"], \"version\": null, \"direction\": \"pullToVoSpace\", \"keepBytes\": null, \"protocols\": [{\"uri\": \"ia2:async-recall\", \"endpoint\": null}]}}, \"results\": null}"; MAPPER.readValue(response, JobSummary.class); } Loading @@ -77,7 +78,7 @@ public class JobSummaryTest { Transfer transfer = new Transfer(); transfer.setVersion("2.1"); transfer.setTarget("vos://example.com!vospace/mydata1"); transfer.setTarget(Arrays.asList("vos://example.com!vospace/mydata1")); transfer.setDirection("pullFromVoSpace"); Protocol protocol1 = new Protocol(); protocol1.setUri("ivo://ivoa.net/vospace/core#httpget"); Loading Loading @@ -109,7 +110,7 @@ public class JobSummaryTest { Transfer transfer = (Transfer) deserializedJob.getJobInfo().getAny().get(0); assertEquals("2.1", transfer.getVersion()); assertEquals("pullFromVoSpace", transfer.getDirection()); assertEquals("vos://example.com!vospace/mydata1", transfer.getTarget()); assertArrayEquals(new String[]{"vos://example.com!vospace/mydata1"}, transfer.getTarget().toArray(String[]::new)); Protocol protocol = transfer.getProtocols().get(0); assertEquals("ivo://ivoa.net/vospace/core#httpget", protocol.getUri()); Loading
src/test/java/net/ivoa/xml/vospace/v2/TransferTest.java +27 −9 Original line number Diff line number Diff line Loading @@ -9,8 +9,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import it.inaf.oats.vospace.datamodel.NodeProperties; import java.io.StringReader; import java.io.StringWriter; import java.util.Arrays; import javax.xml.bind.JAXB; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; public class TransferTest { Loading @@ -20,15 +23,31 @@ public class TransferTest { private static final String URI_PREFIX = "vos://example.com!vospace"; @Test public void testXmlSerialization() throws Exception { public void testSingleTarget() throws Exception { Transfer transfer = getTransfer(); Transfer transfer = getBaseTransfer(); transfer.setTarget(Arrays.asList(URI_PREFIX + "/mynode")); testXmlSerialization(transfer); } @Test public void testMultipleTargets() throws Exception { Transfer transfer = getBaseTransfer(); transfer.setTarget(Arrays.asList(URI_PREFIX + "/mynode1", URI_PREFIX + "/mynode2")); testXmlSerialization(transfer); } private void testXmlSerialization(Transfer transfer) throws Exception { String xml; try ( StringWriter sw = new StringWriter()) { JAXB.marshal(transfer, sw); xml = sw.toString(); System.out.println(xml); assertTrue(xml.contains("<vos:transfer")); } Transfer deserialized; Loading @@ -39,10 +58,9 @@ public class TransferTest { verifyTransfersAreEquals(transfer, deserialized); } private Transfer getTransfer() { Transfer transfer = new Transfer(); private Transfer getBaseTransfer() { transfer.setTarget(URI_PREFIX + "/mynode"); Transfer transfer = new Transfer(); transfer.setDirection("pullFromVoSpace"); Protocol protocol = new Protocol(); Loading @@ -62,7 +80,7 @@ public class TransferTest { private void verifyTransfersAreEquals(Transfer serialized, Transfer deserialized) { assertEquals(serialized.getTarget(), deserialized.getTarget()); assertArrayEquals(serialized.getTarget().toArray(String[]::new), deserialized.getTarget().toArray(String[]::new)); assertEquals(serialized.getDirection(), deserialized.getDirection()); assertEquals(serialized.getProtocols().size(), deserialized.getProtocols().size()); assertEquals(serialized.getParam().size(), deserialized.getParam().size()); Loading