MessageUtil { public static SessionResponseMessage createNewSession(byte[] request, final List<String> languages) { final UUID sessionKey = UUID.randomUUID(); final SessionResponseMessage responseMessage = new SessionResponseMessage(); responseMessage.setSessionAsUUID(sessionKey); responseMessage.Request = request; responseMessage.Languages = new String[languages.size()]; languages.toArray(responseMessage.Languages); return responseMessage; }  static ErrorResponseMessage createErrorResponse(final byte[] request, final byte[] session,
                                                           final Integer flag, final String errorMessage); static SessionResponseMessage createNewSession(byte[] request, final List<String> languages); static SessionResponseMessage createEmptySession(byte[] request);  }
@Test public void createNewSession() { byte [] request = "request".getBytes(); final SessionResponseMessage msg = MessageUtil.createNewSession(request, new ArrayList<String>() {{ add("groovy"); }}); Assert.assertNotNull(msg); Assert.assertEquals(request, msg.Request); Assert.assertEquals("groovy", msg.Languages[0]); final SessionResponseMessage newMsg = MessageUtil.createNewSession(request, new ArrayList<String>() {{ add("groovy"); }}); Assert.assertFalse(Arrays.equals(newMsg.Session, msg.Session)); }