コード例 #1
0
  @Test
  public void shouldBindListOfPrimitive() throws Exception {

    collection.insert("{index:1}");

    List<Integer> indexes = Lists.newArrayList(1, 2);

    long nb = collection.count("{index:{$in:#}}", indexes);

    assertThat(nb).isEqualTo(1);
  }
コード例 #2
0
  @Test
  public void shouldBindAFieldName() throws Exception {

    /* given */
    collection.insert("{name:{1:'John'}}");

    /* when */
    DBObject result = collection.findOne("{name.#:#}", 1, "John").map(new DBObjectResultMapper());

    /* then */
    assertThat(result).isNotNull();
    assertThat(result.get("name")).isInstanceOf(DBObject.class);
    assertThat(((DBObject) result.get("name")).get("1")).isEqualTo("John");
  }