Esempio n. 1
0
  @Test
  public void shouldSelectByZero() {
    FastSelect<TestInt> database = new FastSelectBuilder<>(TestInt.class).blockSize(1).create();
    database.addAll(asList(new TestInt(0), new TestInt(91), new TestInt(89)));

    Assert.assertEquals(
        singletonList(new TestInt(0)), database.select(new IntRequest("intValue", 0)));
  }
Esempio n. 2
0
  @Test
  public void shouldSelectIfManyBlocksOneLevel() {
    FastSelect<TestInt> database = new FastSelectBuilder<>(TestInt.class).blockSize(1).create();
    database.addAll(asList(new TestInt(0), new TestInt(12), new TestInt(0)));

    List result = database.select(new IntRequest("intValue", 12));

    Assert.assertEquals(singletonList(new TestInt(12)), result);
  }
Esempio n. 3
0
  @Test
  public void shouldSelectAndSortByColumn() {
    FastSelect<TestInt> database = new FastSelectBuilder<>(TestInt.class).create();
    database.addAll(asList(new TestInt(11), new TestInt(4), new TestInt(98)));

    Assert.assertEquals(
        asList(new TestInt(4), new TestInt(11), new TestInt(98)),
        database.selectAndSort(new ColumnRequest[0], "intValue"));
  }
Esempio n. 4
0
  @Test
  public void shouldSelectByNotWhenTwoOppositeValuesInSameBlock() {
    FastSelect<TestInt> database = new FastSelectBuilder<>(TestInt.class).blockSize(10).create();
    database.addAll(asList(new TestInt(0), new TestInt(91), new TestInt(89)));

    Assert.assertEquals(
        asList(new TestInt(91), new TestInt(89)),
        database.select(new NotRequest(new IntRequest("intValue", 0))));
  }
Esempio n. 5
0
  @Test
  public void shouldSupportAddMultipleTimes() {
    FastSelect<TestInt> database = new FastSelectBuilder<>(TestInt.class).blockSize(1).create();
    database.addAll(singletonList(new TestInt(Integer.MAX_VALUE)));
    database.addAll(singletonList(new TestInt(0)));
    database.addAll(singletonList(new TestInt(Integer.MIN_VALUE)));

    List result = database.select();

    Assert.assertEquals(
        asList(new TestInt(Integer.MAX_VALUE), new TestInt(0), new TestInt(Integer.MIN_VALUE)),
        result);
  }
Esempio n. 6
0
  @Test
  public void shouldCorrectlyRestoreField() {
    FastSelect<TestInt> database = new FastSelectBuilder<>(TestInt.class).create();
    database.addAll(
        asList(
            new TestInt(0),
            new TestInt(-1),
            new TestInt(1),
            new TestInt(Integer.MAX_VALUE),
            new TestInt(Integer.MIN_VALUE)));

    Assert.assertEquals(
        asList(
            new TestInt(0),
            new TestInt(-1),
            new TestInt(1),
            new TestInt(Integer.MAX_VALUE),
            new TestInt(Integer.MIN_VALUE)),
        database.select());
  }
Esempio n. 7
0
  @Test
  public void selectByBetween() {
    FastSelect<TestInt> database = new FastSelectBuilder<>(TestInt.class).blockSize(1).create();
    database.addAll(
        asList(
            new TestInt(Integer.MIN_VALUE),
            new TestInt(-11),
            new TestInt(0),
            new TestInt(11),
            new TestInt(5),
            new TestInt(4),
            new TestInt(Integer.MAX_VALUE)));

    Assert.assertEquals(
        asList(new TestInt(Integer.MIN_VALUE), new TestInt(-11), new TestInt(0)),
        database.select(new IntBetweenRequest("intValue", Integer.MIN_VALUE, 0)));

    Assert.assertEquals(
        asList(new TestInt(5), new TestInt(4)),
        database.select(new IntBetweenRequest("intValue", 4, 5)));

    Assert.assertEquals(
        Collections.singletonList(new TestInt(4)),
        database.select(new IntBetweenRequest("intValue", 4, 4)));

    Assert.assertEquals(
        Collections.emptyList(), database.select(new IntBetweenRequest("intValue", 5, 4)));
  }