### Question:
AmqpProducer { public static void sendMessage(String topic, ApplicationManagerMessage message, boolean toLog) { if(Configuration.enableAMQP != null && Configuration.enableAMQP.equals("yes")) { String messageString = ModelConverter.applicationManagerMessageToJSON(message); try { AmqpMessageProducer producer = new AmqpMessageProducer(Configuration.amqpAddress, Configuration.amqpUsername, Configuration.amqpPassword, topic, true); producer.sendMessage(messageString); producer.close(); if(toLog) { logger.info("Sending message to: " + topic); logger.info("Message sent: \n" + messageString); } } catch(Exception e) { logger.info("Error trying to send message to the Message Queue for the topic: " + topic); logger.info("Message: " + messageString); logger.info(e.getStackTrace()); } } }  static void sendMessage(String topic, ApplicationManagerMessage message, boolean toLog); static void sendNewApplicationMessage(Application application); static void sendDeploymentSubmittedMessage(Application application); static void sendDeploymentNegotiatingMessage(String applicationName, Deployment deployment); static void sendDeploymentNegotiatedMessage(String applicationName, Deployment deployment); static void sendDeploymentContextualizingMessage(String applicationName, Deployment deployment); static void sendDeploymentContextualizedMessage(String applicationName, Deployment deployment); static void sendDeploymentDeployingMessage(String applicationName, Deployment deployment); static void sendDeploymentDeployedMessage(String applicationName, Deployment deployment); static void sendDeploymentDeletedMessage(String applicationName, Deployment deployment); static void sendDeploymentErrorMessage(String applicationName, Deployment deployment); static void sendVMDeployingMessage(String applicationName, Deployment deployment, VM vm); static void sendVMDeployedMessage(String applicationName, Deployment deployment, VM vm); static void sendVMDeletedMessage(String applicationName, Deployment deployment, VM vm); static void sendDeploymentRenegotiatingMessage(String applicationName, Deployment deployment); static void sendDeploymentRenegotiatedMessage(String applicationName, Deployment deployment); static final String APPLLICATION_PATH; static final String DEPLOYMENT_PATH; static final String VM_PATH; static final String DELETED; }### Answer:
@Test public void sendMessageTest() throws Exception { ApplicationManagerMessage messageToBeSent = new ApplicationManagerMessage(); messageToBeSent.setApplicationId("111"); messageToBeSent.setDeploymentId("222"); messageToBeSent.setStatus("SOMETHING"); AmqpMessageReceiver receiver = new AmqpMessageReceiver(Configuration.amqpAddress, Configuration.amqpUsername, Configuration.amqpPassword, "application.111.deployment.222", true); AmqpBasicListener listener = new AmqpBasicListener(); receiver.setMessageConsumer(listener); AmqpProducer.sendMessage("application.111.deployment.222", messageToBeSent, true); Thread.sleep(700l); assertEquals("application.111.deployment.222", listener.getDestination()); ApplicationManagerMessage amMessageReceived = ModelConverter.jsonToApplicationManagerMessage(listener.getMessage()); assertEquals("111", amMessageReceived.getApplicationId()); assertEquals("222", amMessageReceived.getDeploymentId()); assertEquals("SOMETHING", amMessageReceived.getStatus()); receiver.close(); }