LocalIRKit { public static void postMessage(InetAddress inetAddress, String format, int frequency, int[] data) throws IOException { postMessage(inetAddress, format, frequency, data, 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 postMessage() throws IOException { try { String format = "raw"; int frequency = 38; int[] data = new int[]{18031, 8755, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 3341, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 65535, 0, 9379, 18031, 4400, 1190}; Message message = new Message(format, frequency, data); LocalIRKit.postMessage(null, message, new HttpClient()); fail("IllegalArgumentException is not thrown"); } catch (IllegalArgumentException e) { } try { LocalIRKit.postMessage(mInetAddress, null, new HttpClient()); fail("IllegalArgumentException is not thrown"); } catch (IllegalArgumentException e) { } try { String format = "raw"; int frequency = 38; int[] data = new int[]{18031, 8755, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 3341, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 65535, 0, 9379, 18031, 4400, 1190}; Message message = new Message(format, frequency, data); LocalIRKit.postMessage(mInetAddress, message, 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(httpClient.request(Mockito.notNull(HttpRequest.class))).thenReturn(httpResponse); String format = "raw"; int frequency = 38; int[] data = new int[]{18031, 8755, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 3341, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 65535, 0, 9379, 18031, 4400, 1190}; Message message = new Message(format, frequency, data); LocalIRKit.postMessage(mInetAddress, message, httpClient); } { HttpClient httpClient = mock(HttpClient.class); HttpResponse httpResponse = mock(HttpResponse.class); when(httpResponse.getStatusCode()).thenReturn(200); when(httpClient.request(Mockito.notNull(HttpRequest.class))).thenReturn(httpResponse); String format = "raw"; int frequency = 38; int[] data = new int[]{18031, 8755, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 1190, 1190, 3341, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 3341, 1190, 65535, 0, 9379, 18031, 4400, 1190}; LocalIRKit.postMessage(mInetAddress, format, frequency, data, httpClient); } }