Java Code Examples for org.apache.commons.collections4.queue.CircularFifoQueue#offer()

The following examples show how to use org.apache.commons.collections4.queue.CircularFifoQueue#offer() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenAddElements_whenUsingIntConstructor_correctSizeQueue() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    Assert.assertEquals(FIXED_SIZE, colors.maxSize());
}
 
Example 2
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenAddElements_whenGetElement_correctElement() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    Assert.assertEquals(TEST_COLOR_BY_INDEX, colors.get(1));
}
 
Example 3
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenAddElements_whenPollElement_correctElement() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    Assert.assertEquals(TEST_COLOR, colors.poll());
}
 
Example 4
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenAddElements_whenPeekQueue_correctElement() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    Assert.assertEquals(TEST_COLOR, colors.peek());
}
 
Example 5
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenAddElements_whenElementQueue_correctElement() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    Assert.assertEquals(TEST_COLOR, colors.element());
}
 
Example 6
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenAddElements_whenRemoveElement_correctElement() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    Assert.assertEquals(TEST_COLOR, colors.remove());
}
 
Example 7
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenFullQueue_whenClearQueue_getIsEmpty() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    colors.clear();

    Assert.assertEquals(true, colors.isEmpty());
}
 
Example 8
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenFullQueue_whenCheckFull_getIsFull() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    Assert.assertEquals(false, colors.isFull());
}
 
Example 9
Source File: CircularFifoQueueUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenFullQueue_whenAddMoreElements_getIsAtFullCapacity() {
    CircularFifoQueue<String> colors = new CircularFifoQueue<>(5);
    colors.add("Red");
    colors.add("Blue");
    colors.add("Green");
    colors.offer("White");
    colors.offer("Black");

    colors.add("Orange");
    colors.add("Violet");
    colors.add("Pink");

    Assert.assertEquals(true, colors.isAtFullCapacity());
}