RMQConnectionConfig implements Serializable { public ConnectionFactory getConnectionFactory() throws URISyntaxException, NoSuchAlgorithmException, KeyManagementException { ConnectionFactory factory = new ConnectionFactory(); if (this.uri != null && !this.uri.isEmpty()){ try { factory.setUri(this.uri); } catch (URISyntaxException e) { LOG.error("Failed to parse uri", e); throw e; } catch (KeyManagementException e) { LOG.error("Failed to initialize ssl context.", e); throw e; } catch (NoSuchAlgorithmException e) { LOG.error("Failed to setup ssl factory.", e); throw e; } } else { factory.setHost(this.host); factory.setPort(this.port); factory.setVirtualHost(this.virtualHost); factory.setUsername(this.username); factory.setPassword(this.password); } if (this.automaticRecovery != null) { factory.setAutomaticRecoveryEnabled(this.automaticRecovery); } if (this.connectionTimeout != null) { factory.setConnectionTimeout(this.connectionTimeout); } if (this.networkRecoveryInterval != null) { factory.setNetworkRecoveryInterval(this.networkRecoveryInterval); } if (this.requestedHeartbeat != null) { factory.setRequestedHeartbeat(this.requestedHeartbeat); } if (this.topologyRecovery != null) { factory.setTopologyRecoveryEnabled(this.topologyRecovery); } if (this.requestedChannelMax != null) { factory.setRequestedChannelMax(this.requestedChannelMax); } if (this.requestedFrameMax != null) { factory.setRequestedFrameMax(this.requestedFrameMax); } return factory; } private  RMQConnectionConfig(String host, Integer port, String virtualHost, String username, String password,
								Integer networkRecoveryInterval, Boolean automaticRecovery,
								Boolean topologyRecovery, Integer connectionTimeout, Integer requestedChannelMax,
								Integer requestedFrameMax, Integer requestedHeartbeat); private  RMQConnectionConfig(String uri, Integer networkRecoveryInterval, Boolean automaticRecovery,
								Boolean topologyRecovery, Integer connectionTimeout, Integer requestedChannelMax,
								Integer requestedFrameMax, Integer requestedHeartbeat); String getHost(); int getPort(); String getVirtualHost(); String getUsername(); String getPassword(); String getUri(); Integer getNetworkRecoveryInterval(); Boolean isAutomaticRecovery(); Boolean isTopologyRecovery(); Integer getConnectionTimeout(); Integer getRequestedChannelMax(); Integer getRequestedFrameMax(); Integer getRequestedHeartbeat(); ConnectionFactory getConnectionFactory();  }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointExceptionIfHostIsNull() throws NoSuchAlgorithmException, KeyManagementException, URISyntaxException { RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder() .setPort(1000).setUserName("guest") .setPassword("guest").setVirtualHost("/").build(); connectionConfig.getConnectionFactory(); }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointExceptionIfPortIsNull() throws NoSuchAlgorithmException, KeyManagementException, URISyntaxException { RMQConnectionConfig connectionConfig = new RMQConnectionConfig.Builder() .setHost("localhost").setUserName("guest") .setPassword("guest").setVirtualHost("/").build(); connectionConfig.getConnectionFactory(); }