コード例 #1
0
  @Test
  public void testConstructorWithEmptyCollectionOverwrites() {
    JsonArrayDocument preExisting = JsonArrayDocument.create(uuid, JsonArray.from("test", "test2"));
    bucket.upsert(preExisting);

    Map<String, Object> map =
        new CouchbaseMap<Object>(uuid, bucket, Collections.<String, Object>emptyMap());

    assertEquals(0, map.size());
  }
コード例 #2
0
  @Test
  public void testConstructorWithCollectionDataOverwrites() {
    JsonArrayDocument preExisting = JsonArrayDocument.create(uuid, JsonArray.from("test", "test2"));
    bucket.upsert(preExisting);

    Map<String, Object> map =
        new CouchbaseMap<Object>(uuid, bucket, Collections.singletonMap("foo", "bar"));

    assertEquals(1, map.size());
    assertTrue(map.containsKey("foo"));
    assertEquals("bar", map.get("foo"));
  }
コード例 #3
0
  @Test
  public void testConstructorWithPreExistingDocumentOfWrongTypeFails() {
    JsonArrayDocument preExisting = JsonArrayDocument.create(uuid, JsonArray.from("test"));
    bucket.upsert(preExisting);

    Map<String, Object> map = new CouchbaseMap<Object>(uuid, bucket);
    try {
      map.size();
      fail("Expected TranscodingException");
    } catch (TranscodingException e) {
      // expected
    }
  }