@Test void initShouldThrowWhenNoExchangeParameter() { FakeMailetConfig customMailetConfig = FakeMailetConfig.builder() .mailetName("Test") .mailetContext(mailetContext) .setProperty("uri", AMQP_URI) .build(); assertThatThrownBy(() -> mailet.init(customMailetConfig)) .isInstanceOf(MailetException.class); }
@Override public void init() throws MailetException { String uri = getInitParameter(URI_PARAMETER_NAME); if (Strings.isNullOrEmpty(uri)) { throw new MailetException("No value for " + URI_PARAMETER_NAME + " parameter was provided."); } exchange = getInitParameter(EXCHANGE_PARAMETER_NAME); if (Strings.isNullOrEmpty(exchange)) { throw new MailetException("No value for " + EXCHANGE_PARAMETER_NAME + " parameter was provided."); } routingKey = getInitParameter(ROUTING_KEY_PARAMETER_NAME, ROUTING_KEY_DEFAULT_VALUE); String rawAttribute = getInitParameter(ATTRIBUTE_PARAMETER_NAME); if (Strings.isNullOrEmpty(rawAttribute)) { throw new MailetException("No value for " + ATTRIBUTE_PARAMETER_NAME + " parameter was provided."); } attribute = AttributeName.of(rawAttribute); connectionFactory = new ConnectionFactory(); try { connectionFactory.setUri(uri); } catch (Exception e) { throw new MailetException("Invalid " + URI_PARAMETER_NAME + " parameter was provided: " + uri, e); } }
AmqpForwardAttribute extends GenericMailet { @Override public void init() throws MailetException { String uri = getInitParameter(URI_PARAMETER_NAME); if (Strings.isNullOrEmpty(uri)) { throw new MailetException("No value for " + URI_PARAMETER_NAME + " parameter was provided."); } exchange = getInitParameter(EXCHANGE_PARAMETER_NAME); if (Strings.isNullOrEmpty(exchange)) { throw new MailetException("No value for " + EXCHANGE_PARAMETER_NAME + " parameter was provided."); } routingKey = getInitParameter(ROUTING_KEY_PARAMETER_NAME, ROUTING_KEY_DEFAULT_VALUE); String rawAttribute = getInitParameter(ATTRIBUTE_PARAMETER_NAME); if (Strings.isNullOrEmpty(rawAttribute)) { throw new MailetException("No value for " + ATTRIBUTE_PARAMETER_NAME + " parameter was provided."); } attribute = AttributeName.of(rawAttribute); connectionFactory = new ConnectionFactory(); try { connectionFactory.setUri(uri); } catch (Exception e) { throw new MailetException("Invalid " + URI_PARAMETER_NAME + " parameter was provided: " + uri, e); } } }
AmqpForwardAttribute extends GenericMailet { @Override public void init() throws MailetException { String uri = getInitParameter(URI_PARAMETER_NAME); if (Strings.isNullOrEmpty(uri)) { throw new MailetException("No value for " + URI_PARAMETER_NAME + " parameter was provided."); } exchange = getInitParameter(EXCHANGE_PARAMETER_NAME); if (Strings.isNullOrEmpty(exchange)) { throw new MailetException("No value for " + EXCHANGE_PARAMETER_NAME + " parameter was provided."); } routingKey = getInitParameter(ROUTING_KEY_PARAMETER_NAME, ROUTING_KEY_DEFAULT_VALUE); String rawAttribute = getInitParameter(ATTRIBUTE_PARAMETER_NAME); if (Strings.isNullOrEmpty(rawAttribute)) { throw new MailetException("No value for " + ATTRIBUTE_PARAMETER_NAME + " parameter was provided."); } attribute = AttributeName.of(rawAttribute); connectionFactory = new ConnectionFactory(); try { connectionFactory.setUri(uri); } catch (Exception e) { throw new MailetException("Invalid " + URI_PARAMETER_NAME + " parameter was provided: " + uri, e); } }  }
AmqpForwardAttribute extends GenericMailet { @Override public void init() throws MailetException { String uri = getInitParameter(URI_PARAMETER_NAME); if (Strings.isNullOrEmpty(uri)) { throw new MailetException("No value for " + URI_PARAMETER_NAME + " parameter was provided."); } exchange = getInitParameter(EXCHANGE_PARAMETER_NAME); if (Strings.isNullOrEmpty(exchange)) { throw new MailetException("No value for " + EXCHANGE_PARAMETER_NAME + " parameter was provided."); } routingKey = getInitParameter(ROUTING_KEY_PARAMETER_NAME, ROUTING_KEY_DEFAULT_VALUE); String rawAttribute = getInitParameter(ATTRIBUTE_PARAMETER_NAME); if (Strings.isNullOrEmpty(rawAttribute)) { throw new MailetException("No value for " + ATTRIBUTE_PARAMETER_NAME + " parameter was provided."); } attribute = AttributeName.of(rawAttribute); connectionFactory = new ConnectionFactory(); try { connectionFactory.setUri(uri); } catch (Exception e) { throw new MailetException("Invalid " + URI_PARAMETER_NAME + " parameter was provided: " + uri, e); } }  @Override void init(); @Override void service(Mail mail); @Override String getMailetInfo(); }
AmqpForwardAttribute extends GenericMailet { @Override public void init() throws MailetException { String uri = getInitParameter(URI_PARAMETER_NAME); if (Strings.isNullOrEmpty(uri)) { throw new MailetException("No value for " + URI_PARAMETER_NAME + " parameter was provided."); } exchange = getInitParameter(EXCHANGE_PARAMETER_NAME); if (Strings.isNullOrEmpty(exchange)) { throw new MailetException("No value for " + EXCHANGE_PARAMETER_NAME + " parameter was provided."); } routingKey = getInitParameter(ROUTING_KEY_PARAMETER_NAME, ROUTING_KEY_DEFAULT_VALUE); String rawAttribute = getInitParameter(ATTRIBUTE_PARAMETER_NAME); if (Strings.isNullOrEmpty(rawAttribute)) { throw new MailetException("No value for " + ATTRIBUTE_PARAMETER_NAME + " parameter was provided."); } attribute = AttributeName.of(rawAttribute); connectionFactory = new ConnectionFactory(); try { connectionFactory.setUri(uri); } catch (Exception e) { throw new MailetException("Invalid " + URI_PARAMETER_NAME + " parameter was provided: " + uri, e); } }  @Override void init(); @Override void service(Mail mail); @Override String getMailetInfo(); static final String URI_PARAMETER_NAME; static final String EXCHANGE_PARAMETER_NAME; static final String ROUTING_KEY_PARAMETER_NAME; static final String ATTRIBUTE_PARAMETER_NAME; static final String ROUTING_KEY_DEFAULT_VALUE; }