コード例 #1
0
  @Test
  public void testBulkSQLUpdateWithMultipleCriteria() {
    Owner owner = this.createOwner();

    Content c1 = this.createContent("c1", "content 1", owner);
    Content c2 = this.createContent("c2", "content 2", owner);
    Content c3 = this.createContent("c3", "content 3", owner);

    Map<Object, Object> values = new HashMap<Object, Object>();
    values.put("content 1", "update 1");
    values.put("content 2", "update 2");
    values.put("content ?", "should not exist");

    Map<String, Object> criteria = new HashMap<String, Object>();
    criteria.put("name", values.keySet());
    criteria.put("content_id", "c2");

    int result = this.testContentCurator.bulkSQLUpdate(Content.DB_TABLE, "name", values, criteria);

    // Unlike the base test where the result count is 3, this filters by only the values we
    // intend to update, so it should be 1.
    assertEquals(1, result);

    testContentCurator.refresh(c1, c2, c3);

    assertEquals("content 1", c1.getName());
    assertEquals("update 2", c2.getName());
    assertEquals("content 3", c3.getName());
  }
コード例 #2
0
  @Test
  public void testBulkSQLUpdate() throws Exception {
    Owner owner = this.createOwner();

    Content c1 = this.createContent("c1", "content 1", owner);
    Content c2 = this.createContent("c2", "content 2", owner);
    Content c3 = this.createContent("c3", "content 3", owner);

    Map<Object, Object> values = new HashMap<Object, Object>();
    values.put("content 1", "update 1");
    values.put("content 2", "update 2");
    values.put("content ?", "should not exist");

    int result = this.testContentCurator.bulkSQLUpdate(Content.DB_TABLE, "name", values, null);

    // Note:
    // This looks like it should be 2, and technically that's what's happening here, but with
    // the way the bulk updater works, even the non-matching columns are getting updated to
    // themselves.
    assertEquals(3, result);

    testContentCurator.refresh(c1, c2, c3);

    assertEquals("update 1", c1.getName());
    assertEquals("update 2", c2.getName());
    assertEquals("content 3", c3.getName());
  }
コード例 #3
0
  @Test
  public void testBulkSQLUpdateWithEmptyValues() throws Exception {
    Owner owner = this.createOwner();

    Content c1 = this.createContent("c1", "content 1", owner);
    Content c2 = this.createContent("c2", "content 2", owner);
    Content c3 = this.createContent("c3", "content 3", owner);

    Map<Object, Object> values = new HashMap<Object, Object>();

    int result = this.testContentCurator.bulkSQLUpdate(Content.DB_TABLE, "name", values, null);

    assertEquals(0, result);

    testContentCurator.refresh(c1, c2, c3);

    assertEquals("content 1", c1.getName());
    assertEquals("content 2", c2.getName());
    assertEquals("content 3", c3.getName());
  }