RemEvidenceFactory implements EvidenceFactory { @Override public void write(OutputStream outputStream, TransmissionResult transmissionResult) throws EvidenceException { try { Evidence evidence = Evidence.newInstance() .type(EvidenceTypeInstance.DELIVERY_NON_DELIVERY_TO_RECIPIENT) .eventCode(EventCode.DELIVERY) .issuer(ISSUER) .evidenceIdentifier(InstanceIdentifier.generateUUID()) .timestamp(transmissionResult.getTimestamp()) .header(transmissionResult.getHeader()) .digest(transmissionResult.getDigest()) .messageIdentifier(transmissionResult.getTransmissionIdentifier()) .transportProtocol(transmissionResult.getTransportProtocol()) .transmissionRole(transmissionResult instanceof TransmissionResponse ? TransmissionRole.C_2 : TransmissionRole.C_3) .originalReceipts(transmissionResult.getReceipts()); SignedEvidenceWriter.write(outputStream, privateKeyEntry, evidence); } catch (RemEvidenceException | PeppolSecurityException e) { throw new EvidenceException(e.getMessage(), e); } } @Inject  RemEvidenceFactory(KeyStore.PrivateKeyEntry privateKeyEntry); @Override void write(OutputStream outputStream, TransmissionResult transmissionResult);  }
@Test public void simple() throws IOException, EvidenceException { Assert.assertNotNull(evidenceFactory); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); evidenceFactory.write(outputStream, createMockTransmissionResponse()); log.info(new String(outputStream.toByteArray())); }
@Test(expectedExceptions = EvidenceException.class) public void triggerException() throws IOException, EvidenceException { evidenceFactory.write(null, createMockTransmissionResponse()); }