WorkflowConfigurationFactory { private WorkflowTrace createHandshakeWorkflow() { return createHandshakeWorkflow(getConnection()); } WorkflowConfigurationFactory(Config config); WorkflowTrace createWorkflowTrace(WorkflowTraceType type, RunningModeType mode); WorkflowTrace createTlsEntryWorkflowtrace(AliasedConnection connection); WorkflowTrace createHelloWorkflow(AliasedConnection connection); boolean shouldServerSendACertificate(CipherSuite suite); ClientKeyExchangeMessage createClientKeyExchangeMessage(KeyExchangeAlgorithm algorithm); ServerKeyExchangeMessage createServerKeyExchangeMessage(KeyExchangeAlgorithm algorithm); void addClientKeyExchangeMessage(List<ProtocolMessage> messages); void addServerKeyExchangeMessage(List<ProtocolMessage> messages); WorkflowTrace addStartTlsActions(AliasedConnection connection, StarttlsType type, WorkflowTrace workflowTrace);  }
@Test() public void testCreateHandshakeWorkflow() { WorkflowTrace handshakeWorkflow; MessageAction lastAction; MessageAction messageAction4; ReceiveAction receiveAction; config.setHighestProtocolVersion(ProtocolVersion.TLS13); config.setClientAuthentication(false); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); handshakeWorkflow = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HANDSHAKE, RunningModeType.CLIENT); Assert.assertThat(handshakeWorkflow.getMessageActions().size(), Matchers.greaterThanOrEqualTo(3)); Assert.assertNotNull(handshakeWorkflow.getLastMessageAction()); lastAction = handshakeWorkflow.getLastMessageAction(); Assert.assertEquals(FinishedMessage.class, lastAction.getMessages().get(lastAction.getMessages().size() - 1) .getClass()); config.setClientAuthentication(true); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); handshakeWorkflow = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HANDSHAKE, RunningModeType.CLIENT); lastAction = handshakeWorkflow.getLastMessageAction(); Assert.assertEquals(ChangeCipherSpecMessage.class, lastAction.getMessages().get(0).getClass()); Assert.assertEquals(CertificateMessage.class, lastAction.getMessages().get(1).getClass()); Assert.assertEquals(CertificateVerifyMessage.class, lastAction.getMessages().get(2).getClass()); Assert.assertEquals(FinishedMessage.class, lastAction.getMessages().get(3).getClass()); config.setHighestProtocolVersion(ProtocolVersion.DTLS10); config.setClientAuthentication(true); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); handshakeWorkflow = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.HANDSHAKE, RunningModeType.CLIENT); Assert.assertThat(handshakeWorkflow.getMessageActions().size(), Matchers.greaterThanOrEqualTo(6)); messageAction4 = handshakeWorkflow.getMessageActions().get(4); Assert.assertEquals(CertificateMessage.class, messageAction4.getMessages().get(0).getClass()); Assert.assertEquals(CertificateVerifyMessage.class, messageAction4.getMessages().get(messageAction4.getMessages().size() - 3).getClass()); Assert.assertEquals(ChangeCipherSpecMessage.class, messageAction4.getMessages().get(messageAction4.getMessages().size() - 2).getClass()); Assert.assertEquals(FinishedMessage.class, messageAction4.getMessages().get(messageAction4.getMessages().size() - 1).getClass()); receiveAction = (ReceiveAction) handshakeWorkflow.getLastMessageAction(); Assert.assertEquals(ChangeCipherSpecMessage.class, receiveAction.getExpectedMessages().get(0).getClass()); Assert.assertEquals(FinishedMessage.class, receiveAction.getExpectedMessages().get(1).getClass()); }