RemoteDocumentConverter { public static DSSDocument toDSSDocument(RemoteDocument remoteDocument) { if (remoteDocument == null || Utils.isArrayEmpty(remoteDocument.getBytes())) { return null; } if (remoteDocument.getDigestAlgorithm() != null) { DigestDocument digestDocument = new DigestDocument(remoteDocument.getDigestAlgorithm(), Utils.toBase64(remoteDocument.getBytes())); digestDocument.setName(remoteDocument.getName()); return digestDocument; } else { return new InMemoryDocument(remoteDocument.getBytes(), remoteDocument.getName()); } } private  RemoteDocumentConverter(); static List<DSSDocument> toDSSDocuments(List<RemoteDocument> remoteDocuments); static DSSDocument toDSSDocument(RemoteDocument remoteDocument); static List<RemoteDocument> toRemoteDocuments(List<DSSDocument> originalDocuments); static RemoteDocument toRemoteDocument(DSSDocument originalDocument);  }
@Test public void toDSSDocumentTest() { RemoteDocument remoteDocument = new RemoteDocument(new byte[] {'1','2','3'}, "remoteDocument"); DSSDocument dssDocument = RemoteDocumentConverter.toDSSDocument(remoteDocument); assertEquals(Utils.toBase64(DSSUtils.digest(DigestAlgorithm.SHA256, remoteDocument.getBytes())), dssDocument.getDigest(DigestAlgorithm.SHA256)); assertEquals(remoteDocument.getName(), dssDocument.getName()); }
@Test public void toDSSDigestDocumentTest() { RemoteDocument remoteDocument = new RemoteDocument(new byte[] {'1','2','3'}, DigestAlgorithm.SHA256, "remoteDocument"); DSSDocument dssDocument = RemoteDocumentConverter.toDSSDocument(remoteDocument); assertEquals(Utils.toBase64(remoteDocument.getBytes()), dssDocument.getDigest(remoteDocument.getDigestAlgorithm())); assertEquals(remoteDocument.getName(), dssDocument.getName()); }