WorkflowConfigurationFactory { private WorkflowTrace createFullWorkflow() { AliasedConnection connection = getConnection(); WorkflowTrace workflowTrace = this.createHandshakeWorkflow(connection); if (config.isServerSendsApplicationData()) { workflowTrace.addTlsAction(MessageActionFactory.createAction(connection, ConnectionEndType.SERVER, new ApplicationMessage(config))); } if (config.isAddHeartbeatExtension()) { workflowTrace.addTlsAction(MessageActionFactory.createAction(connection, ConnectionEndType.CLIENT, new ApplicationMessage(config), new HeartbeatMessage(config))); workflowTrace.addTlsAction(MessageActionFactory.createAction(connection, ConnectionEndType.SERVER, new HeartbeatMessage(config))); } else { workflowTrace.addTlsAction(MessageActionFactory.createAction(connection, ConnectionEndType.CLIENT, new ApplicationMessage(config))); } return workflowTrace; } 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 testCreateFullWorkflow() { MessageAction messageAction3; MessageAction messageAction4; MessageAction messageAction5; config.setHighestProtocolVersion(ProtocolVersion.TLS13); config.setClientAuthentication(true); config.setServerSendsApplicationData(false); config.setAddHeartbeatExtension(false); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); WorkflowTrace fullWorkflow = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.FULL, RunningModeType.CLIENT); Assert.assertThat(fullWorkflow.getMessageActions().size(), Matchers.greaterThanOrEqualTo(4)); messageAction3 = fullWorkflow.getMessageActions().get(3); Assert.assertEquals(ApplicationMessage.class, messageAction3.getMessages().get(0).getClass()); config.setServerSendsApplicationData(true); config.setAddHeartbeatExtension(true); workflowConfigurationFactory = new WorkflowConfigurationFactory(config); fullWorkflow = workflowConfigurationFactory.createWorkflowTrace(WorkflowTraceType.FULL, RunningModeType.CLIENT); Assert.assertThat(fullWorkflow.getMessageActions().size(), Matchers.greaterThanOrEqualTo(6)); messageAction3 = fullWorkflow.getMessageActions().get(3); messageAction4 = fullWorkflow.getMessageActions().get(4); messageAction5 = fullWorkflow.getMessageActions().get(5); Assert.assertEquals(ReceiveAction.class, messageAction3.getClass()); Assert.assertEquals(ApplicationMessage.class, ((ReceiveAction) messageAction3).getExpectedMessages().get(0) .getClass()); Assert.assertEquals(ApplicationMessage.class, messageAction4.getMessages().get(0).getClass()); Assert.assertEquals(HeartbeatMessage.class, messageAction4.getMessages().get(1).getClass()); Assert.assertEquals(ReceiveAction.class, messageAction5.getClass()); Assert.assertEquals(HeartbeatMessage.class, ((ReceiveAction) messageAction5).getExpectedMessages().get(0) .getClass()); }