@Test public void testGetInstance() { JMeadowsConfiguration jMeadowsConfiguration = new JMeadowsConfiguration(mockEnvironment); JMeadowsData jMeadowsData1 = JMeadowsClientFactory.getInstance(jMeadowsConfiguration); assertNotNull(jMeadowsData1); JMeadowsData jMeadowsData2 = JMeadowsClientFactory.getInstance(jMeadowsConfiguration); assertThat(jMeadowsData1, sameInstance(jMeadowsData2)); when(mockEnvironment.getProperty(HmpProperties.JMEADOWS_URL)) .thenReturn("different.url"); JMeadowsConfiguration jMeadowsConfiguration2 = new JMeadowsConfiguration(mockEnvironment); jMeadowsData1 = JMeadowsClientFactory.getInstance(jMeadowsConfiguration); assertNotNull(jMeadowsData1); jMeadowsData2 = JMeadowsClientFactory.getInstance(jMeadowsConfiguration2); assertTrue(jMeadowsData1 != jMeadowsData2); }
public static JMeadowsData getInstance(IJMeadowsConfiguration jMeadowsConfiguration) { JMeadowsData client = CLIENT_CACHE.getIfPresent(jMeadowsConfiguration); if (client == null) { try { client = create(jMeadowsConfiguration.getUrl(), jMeadowsConfiguration.getTimeoutMS()); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); return null; } CLIENT_CACHE.put(jMeadowsConfiguration, client); } return client; }
JMeadowsClientFactory { public static JMeadowsData getInstance(IJMeadowsConfiguration jMeadowsConfiguration) { JMeadowsData client = CLIENT_CACHE.getIfPresent(jMeadowsConfiguration); if (client == null) { try { client = create(jMeadowsConfiguration.getUrl(), jMeadowsConfiguration.getTimeoutMS()); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); return null; } CLIENT_CACHE.put(jMeadowsConfiguration, client); } return client; } }
JMeadowsClientFactory { public static JMeadowsData getInstance(IJMeadowsConfiguration jMeadowsConfiguration) { JMeadowsData client = CLIENT_CACHE.getIfPresent(jMeadowsConfiguration); if (client == null) { try { client = create(jMeadowsConfiguration.getUrl(), jMeadowsConfiguration.getTimeoutMS()); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); return null; } CLIENT_CACHE.put(jMeadowsConfiguration, client); } return client; }  }
JMeadowsClientFactory { public static JMeadowsData getInstance(IJMeadowsConfiguration jMeadowsConfiguration) { JMeadowsData client = CLIENT_CACHE.getIfPresent(jMeadowsConfiguration); if (client == null) { try { client = create(jMeadowsConfiguration.getUrl(), jMeadowsConfiguration.getTimeoutMS()); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); return null; } CLIENT_CACHE.put(jMeadowsConfiguration, client); } return client; }  static JMeadowsData getInstance(IJMeadowsConfiguration jMeadowsConfiguration); }
JMeadowsClientFactory { public static JMeadowsData getInstance(IJMeadowsConfiguration jMeadowsConfiguration) { JMeadowsData client = CLIENT_CACHE.getIfPresent(jMeadowsConfiguration); if (client == null) { try { client = create(jMeadowsConfiguration.getUrl(), jMeadowsConfiguration.getTimeoutMS()); } catch (MalformedURLException e) { logger.error(e.getMessage(), e); return null; } CLIENT_CACHE.put(jMeadowsConfiguration, client); } return client; }  static JMeadowsData getInstance(IJMeadowsConfiguration jMeadowsConfiguration);  }