### Question:
Message { public void setArgument(String argumentName, Object argument) { ArgumentType argType = null; for (ArgumentType a : messageType.getArguments()) { if (argumentName.equals(a.getName())) { argType = a; } } if (argType == null) { throw new IllegalArgumentException("Invalid argument name for Message: " + argumentName + " (Message type: " + messageType.getName() + ')'); } @SuppressWarnings("rawtypes") Class argumentClass = getTypeForName(argType.getType()); if (!argumentClass.isInstance(argument)) { throw new IllegalArgumentException("Invalid argument type for Message: " + argument + " (Expected " + argType.getType() + ", got " + argument.getClass() + ')'); } argumentsByName.put(argumentName, argument); } Message(MessageType type, Object... args);   Message(MessageType messageType); static Class getTypeForName(String name); void setArgument(String argumentName, Object argument); Object getArgument(String argumentName); short getID(); final Object[] getArgs(); @Override String toString(); final String name; }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void testInvalidName() { Message msg = MESSAGE_REGISTRY.createMessage("InvalidMessage"); msg.setArgument("FooBar", 1337); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testInvalidArgumentType() { Message msg = MESSAGE_REGISTRY.createMessage("InvalidMessage"); msg.setArgument("messageName", "FooBar"); msg.setArgument("messageID", "I'm totally a short, you guys."); }