OperationQueue extends ConcurrentLinkedQueue<GattOperation> { public GattOperation getFirst() { GattOperation operation = null; Iterator iter = this.iterator(); if (iter.hasNext()) { operation = (GattOperation) iter.next(); if (!operation.hasNested()) { return poll(); } OperationQueue bundle = operation.getNestedQueue(); return bundle.getFirst(); } return operation; }  GattOperation getFirst();  }
@Test public void getFirstOperation() { ApduPackage apduPackage = getTestApduPackage(); GattOperation operation = new GattApduOperation("1", apduPackage); OperationQueue queue = new OperationQueue(); queue.add(operation); Assert.assertEquals(1, queue.size()); int size = 0; while (queue.getFirst() != null) { size++; } Assert.assertEquals("total gatt operations", 26, size); }