/** * Creates a list of service definitions. * * @param endpointDefinitions vararg array of service definitions * @return list of service definitions */ public static List<EndpointDefinition> serviceDefinitions(final EndpointDefinition... endpointDefinitions) { return Lists.list(endpointDefinitions); }
@RequestMapping(value = "/sendEmployeesWithReturnArray", method = RequestMethod.POST) public boolean sendEmployeesWithReturnArray(final Employee[] employeeList) { System.out.println("Array " + Lists.list(employeeList)); return true; }
@RequestMapping(value = "/sendEmployeesWithCallbackArray", method = RequestMethod.POST) public void sendEmployeesWithCallbackArray(final Callback<Boolean> callback, final Employee[] employeeList) { System.out.println("Array " + Lists.list(employeeList)); callback.resolve(true); }
@RequestMapping(value = "/emp", method = RequestMethod.POST) public List<Employee> getAddEmployee(Employee employee) { return Lists.list(new Employee("Rick")); } }
@Test public void basicSendTwoItemsWithIterableUsingBatchGet() { sendQueue.sendBatch((Iterable<String>) Lists.list("hi", "mom")); sendQueue.flushSends(); final Iterable<String> items = receiveQueue.readBatch(); final Iterator<String> iterator = items.iterator(); final String item1 = iterator.next(); final String item2 = iterator.next(); assertEquals("hi", item1); assertEquals("mom", item2); }
@Test public void addDepartment() { final HttpTextResponse httpResponse = httpServerSimulator.postBody("/hr/department/100/", new Department(100, Lists.list(new Employee(1, "Rick"), new Employee(2, "Diana")))); assertEquals(200, httpResponse.code()); assertEquals("true", httpResponse.body()); final List<Department> departments = hrService.getDepartments(); assertEquals(1, departments.size()); assertEquals(100, departments.get(0).getId()); }
@Test public void testListWithReturnSet() { final HttpTextResponse httpResponse = httpServerSimulator.postBody("/es/sendEmployeesWithReturnSet", Lists.list(new Employee(1, "Rick"), new Employee(2, "Diana"))); assertEquals(200, httpResponse.code()); assertEquals("true", httpResponse.body()); }
@Test public void testSet() { final HttpTextResponse httpResponse = httpServerSimulator.postBody("/es/sendEmployeesSet", Lists.list(new Employee(1, "Rick"), new Employee(2, "Diana"))); assertEquals(202, httpResponse.code()); assertEquals("\"success\"", httpResponse.body()); }
@Test public void testListWithReturnArray() { final HttpTextResponse httpResponse = httpServerSimulator.postBody("/es/sendEmployeesWithReturnArray", Lists.list(new Employee(1, "Rick"), new Employee(2, "Diana"))); assertEquals(200, httpResponse.code()); assertEquals("true", httpResponse.body()); }
@Test public void testList() { final HttpTextResponse httpResponse = httpServerSimulator.postBody("/es/sendEmployees", Lists.list(new Employee(1, "Rick"), new Employee(2, "Diana"))); assertEquals(202, httpResponse.code()); assertEquals("\"success\"", httpResponse.body()); }
@Test public void testListWithReturn() { final HttpTextResponse httpResponse = httpServerSimulator.postBody("/es/sendEmployeesWithReturn", Lists.list(new Employee(1, "Rick"), new Employee(2, "Diana"))); assertEquals(200, httpResponse.code()); assertEquals("true", httpResponse.body()); }
@Test public void testSendEmployeesWithCallback() { final HttpTextResponse httpResponse = httpServerSimulator.postBody("/es/sendEmployeesWithCallback", Lists.list(new Employee(1, "Rick"), new Employee(2, "Diana"))); assertEquals(200, httpResponse.code()); assertEquals("true", httpResponse.body()); }
@Test public void testSendConsume2() throws Exception { personSendQueue.sendAndFlush(Lists.list(new Person("Geoff"))); personSendQueue.sendAndFlush(Lists.list(new Person("Rick"))); final List<Person> geoff = personReceiveQueue.pollWait(); Sys.sleep(100); final List<Person> rick = personReceiveQueue.pollWait(); assertEquals("Geoff", geoff.get(0).name); assertEquals("Rick", rick.get(0).name); }
@Test public void testTimingNoAvg() throws Exception { collector.replicateTiming("foo.bar.timing1", 2, -1); collector.replicateTiming("foo.bar.timing1", 3, -1); collector.replicateTiming("foo.bar.timing1", 4, -1); collector.queueProcess(); final Map<String, Map<String, ?>> collectMap = collector.collect(); final Map<String, ?> metricsC = collectMap.get("MetricsMS"); assertEquals(Lists.list(2L, 3L, 4L), metricsC.get("foo.bar.timing1")); }
@Test public void getEmployee() { httpServerSimulator.postBody("/hr/department/100/", new Department(100, Lists.list(new Employee(1, "Rick"), new Employee(2, "Diana")))); HttpTextResponse httpResponse = httpServerSimulator.get("/hr/department/100/employee/2"); assertEquals(200, httpResponse.code()); Employee employee = JsonFactory.fromJson(httpResponse.body(), Employee.class); assertEquals(2, employee.getId()); assertEquals("Diana", employee.getName()); }
@Test public void basicSendTwoItemsWithCollection() { sendQueue.sendBatch(Lists.list("hi", "mom")); sendQueue.flushSends(); final String item1 = receiveQueue.pollWait(); final String item2 = receiveQueue.poll(); assertEquals("hi", item1); assertEquals("mom", item2); }
@Test public void basicSendTwoItemsWithIterable() { sendQueue.sendBatch((Iterable<String>) Lists.list("hi", "mom")); sendQueue.flushSends(); final String item1 = receiveQueue.pollWait(); final String item2 = receiveQueue.poll(); assertEquals("hi", item1); assertEquals("mom", item2); }
@Test public void basicSendTwoItemsWithRealIterable() { final List<String> list = Lists.list("hi", "mom"); Iterable<String> iterable = list::iterator; sendQueue.sendBatch(iterable); sendQueue.flushSends(); final String item1 = receiveQueue.pollWait(); final String item2 = receiveQueue.poll(); assertEquals("hi", item1); assertEquals("mom", item2); }
@Test public void basicSendTwoItemsWithIterableUsingTake() { sendQueue.sendBatch((Iterable<String>) Lists.list("hi", "mom")); sendQueue.flushSends(); final String item1 = receiveQueue.take(); final String item2 = receiveQueue.take(); assertEquals("hi", item1); assertEquals("mom", item2); }
@Test public void testSendConsume4() throws Exception { personSendQueue = personQueue.sendQueueWithAutoFlush(QBit.factory().periodicScheduler(), 10, TimeUnit.MILLISECONDS); personSendQueue.sendBatch(Lists.list(new Person("Geoff"), new Person("Rick"))); final Person geoff = personReceiveQueue.take(); final Person rick = personReceiveQueue.take(); assertEquals("Geoff", geoff.name); assertEquals("Rick", rick.name); }