DefaultTransmitter extends Traceable implements Transmitter { @Override public TransmissionResponse transmit(TransmissionMessage transmissionMessage, Span root) throws OxalisTransmissionException { Span span = tracer.buildSpan("transmit").asChildOf(root).start(); try { return perform(transmissionMessage, span); } finally { span.finish(); } } @Inject  DefaultTransmitter(MessageSenderFactory messageSenderFactory, StatisticsService statisticsService,
                              TransmissionVerifier transmissionVerifier, LookupService lookupService, Tracer tracer,
                              OxalisCertificateValidator certificateValidator, ErrorTracker errorTracker); @Override TransmissionResponse transmit(TransmissionMessage transmissionMessage, Span root); @Override TransmissionResponse transmit(TransmissionMessage transmissionMessage);  }
@Test(expectedExceptions = OxalisTransmissionException.class) public void simple() throws Exception { TransmissionRequest transmissionRequest = Mockito.mock(TransmissionRequest.class); Mockito.when(transmissionRequest.getEndpoint()).thenReturn(Endpoint.of( TransportProfile.of("busdox-transport-dummy"), URI.create("http: Mockito.when(transmissionRequest.getPayload()) .thenReturn(new ByteArrayInputStream("".getBytes())); Transmitter transmitter = new DefaultTransmitter(messageSenderFactory, statisticsService, new DefaultTransmissionVerifier(), lookupService, tracer, new OxalisCertificateValidator(CertificateValidator.EMPTY, tracer), new SilentErrorTracker()); transmitter.transmit(transmissionRequest); }
@Test(expectedExceptions = OxalisTransmissionException.class) public void throwException() throws Exception { MessageSenderFactory messageSenderFactory = Mockito.mock(MessageSenderFactory.class); Mockito.when(messageSenderFactory.getMessageSender(Mockito.any(TransportProfile.class))) .thenThrow(new OxalisTransmissionException("From unit test")); TransmissionRequest transmissionRequest = Mockito.mock(TransmissionRequest.class); Mockito.when(transmissionRequest.getEndpoint()) .thenReturn(Endpoint.of(TransportProfile.AS2_1_0, URI.create("http: Transmitter transmitter = new DefaultTransmitter(messageSenderFactory, statisticsService, new DefaultTransmissionVerifier(), lookupService, tracer, new OxalisCertificateValidator(CertificateValidator.EMPTY, tracer), new SilentErrorTracker()); transmitter.transmit(transmissionRequest); }