ValidationRequestToProxyDocumentTransformer { public ProxyDocument transform(ValidationRequest validationRequest) { ProxyDocument proxyDocument = new ProxyDocument(); proxyDocument.setName(validationRequest.getFilename()); proxyDocument.setBytes(Base64.decodeBase64(validationRequest.getDocument())); proxyDocument.setSignaturePolicy(validationRequest.getSignaturePolicy()); setDocumentType(validationRequest, proxyDocument); setReportType(validationRequest, proxyDocument); return proxyDocument; }  ProxyDocument transform(ValidationRequest validationRequest);  }
@Test public void signaturePolicyRemainsUnchanged() { ProxyDocument proxyDocument = transformer.transform(validationRequest); assertEquals(validationRequest.getSignaturePolicy(), proxyDocument.getSignaturePolicy()); }
@Test public void filenameRemainsUnchanged() { assertEquals(validationRequest.getFilename(), transformer.transform(validationRequest).getName()); }
@Test public void pdfTypeIsCorrectlyTransformedToDocumentType() { assertEquals(DocumentType.PDF, transformer.transform(validationRequest).getDocumentType()); }
@Test public void bdocTypeIsCorrectlyTransformedToDocumentType() { validationRequest.setType("bdoc"); assertEquals(DocumentType.BDOC, transformer.transform(validationRequest).getDocumentType()); }
@Test public void ddocTypeIsCorrectlyTransformedToDocumentType() { validationRequest.setType("ddoc"); assertEquals(DocumentType.DDOC, transformer.transform(validationRequest).getDocumentType()); }
@Test public void xroadTypeIsCorrectlyTransformedToDocumentType() { validationRequest.setType("xroad"); assertEquals(DocumentType.XROAD, transformer.transform(validationRequest).getDocumentType()); }
@Test public void contentIsCorrectlyTransformedToBytes() { ProxyDocument proxyDocument = transformer.transform(validationRequest); assertEquals(validationRequest.getDocument(), Base64.encodeBase64String(proxyDocument.getBytes())); }
@Test public void unsupportedTypeThrowsException() { validationRequest = MockValidationRequestBuilder.aValidationRequest().withType("unsupported").build(); expectedException.expect(RuntimeException.class); expectedException.expectMessage("type = unsupported is unsupported"); transformer.transform(validationRequest); }