MessageActionFactory { public static MessageAction createAction(AliasedConnection connection, ConnectionEndType sendingConnectionEndType, ProtocolMessage... protocolMessages) { return createAction(connection, sendingConnectionEndType, new ArrayList<>(Arrays.asList(protocolMessages))); } private  MessageActionFactory(); static MessageAction createAction(AliasedConnection connection, ConnectionEndType sendingConnectionEndType,
            ProtocolMessage... protocolMessages); static MessageAction createAction(AliasedConnection connection, ConnectionEndType sendingConnectionEnd,
            List<ProtocolMessage> protocolMessages); static AsciiAction createAsciiAction(AliasedConnection connection, ConnectionEndType sendingConnectionEnd,
            String message, String encoding);  }
@Test public void testCreateActionOne() { MessageAction action = MessageActionFactory.createAction(clientConnection, ConnectionEndType.CLIENT, new AlertMessage(config)); assertEquals(action.getClass(), SendAction.class); action = MessageActionFactory .createAction(clientConnection, ConnectionEndType.SERVER, new AlertMessage(config)); assertEquals(action.getClass(), ReceiveAction.class); action = MessageActionFactory .createAction(serverConnection, ConnectionEndType.CLIENT, new AlertMessage(config)); assertEquals(action.getClass(), ReceiveAction.class); action = MessageActionFactory .createAction(serverConnection, ConnectionEndType.SERVER, new AlertMessage(config)); assertEquals(action.getClass(), SendAction.class); assertTrue(action.messages.size() == 1); }
@Test public void testCreateActionMultiple() { List<ProtocolMessage> messages = new LinkedList<>(); messages.add(new ChangeCipherSpecMessage()); messages.add(new AlertMessage(config)); MessageAction action = MessageActionFactory.createAction(clientConnection, ConnectionEndType.CLIENT, messages); assertEquals(action.getClass(), SendAction.class); action = MessageActionFactory.createAction(clientConnection, ConnectionEndType.SERVER, messages); assertEquals(action.getClass(), ReceiveAction.class); action = MessageActionFactory.createAction(serverConnection, ConnectionEndType.CLIENT, messages); assertEquals(action.getClass(), ReceiveAction.class); action = MessageActionFactory.createAction(serverConnection, ConnectionEndType.SERVER, messages); assertEquals(action.getClass(), SendAction.class); assertTrue(action.messages.size() == 2); }