LocalIRKit { public static String getKeys(InetAddress inetAddress) throws IOException { return getKeys(inetAddress, new HttpClient()); } private  LocalIRKit(); static String getKeys(InetAddress inetAddress); static Message getMessage(InetAddress inetAddress); static void postMessage(InetAddress inetAddress, String format, int frequency, int[] data); static void postMessage(InetAddress inetAddress, String format, int frequency, int[] data, HttpClient httpClient); static void postMessage(InetAddress inetAddress, Message message); static void postWifi(InetAddress inetAddress, Serializer.WifiSecurity wifiSecurity, String ssid, String password, String deviceKey);  }
@Test public void getKeys() throws IOException { try { LocalIRKit.getKeys(null, new HttpClient()); fail("IllegalArgumentException is not thrown"); } catch (IllegalArgumentException e) { } try { LocalIRKit.getKeys(mInetAddress, null); fail("IllegalArgumentException is not thrown"); } catch (IllegalArgumentException e) { } { HttpClient httpClient = mock(HttpClient.class); HttpResponse httpResponse = mock(HttpResponse.class); when(httpResponse.getStatusCode()).thenReturn(200); when(httpResponse.getContent()).thenReturn("{\"clienttoken\": \"something\"}"); when(httpClient.request(Mockito.notNull(HttpRequest.class))).thenReturn(httpResponse); String clientToken = LocalIRKit.getKeys(mInetAddress, httpClient); assertThat(clientToken, is("something")); } { HttpClient httpClient = mock(HttpClient.class); HttpResponse httpResponse = mock(HttpResponse.class); when(httpResponse.getStatusCode()).thenReturn(500); when(httpClient.request(Mockito.notNull(HttpRequest.class))).thenReturn(httpResponse); try { LocalIRKit.getKeys(mInetAddress, httpClient); fail("UnexpectedStatusCodeException is not thrown"); } catch (UnexpectedStatusCodeException e) { } } }