コード例 #1
0
  @Test
  @Parameters(method = "largeValueSetSizes")
  public void testBulkSQLUpdateWithLargeValueSets(int count, int skip) {
    Owner owner = this.createOwner();

    for (int i = 1; i <= count; ++i) {
      this.createContent("c" + i, "content-" + i, owner);
    }

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

    for (int i = 1; i <= count; ++i) {
      // We want every odd value to be unaffected, but we still want a fake update entry
      // for the query
      values.put("content-" + (i % 2 == skip ? i : "X" + i), "update-" + i);
    }

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

    testContentCurator.clear();

    for (int i = 1; i <= count; ++i) {
      Content content = this.ownerContentCurator.getContentById(owner, "c" + i);

      if (i % 2 == skip) {
        assertEquals("update-" + i, content.getName());
      } else {
        assertEquals("content-" + i, content.getName());
      }
    }
  }
コード例 #2
0
  @Test
  @Parameters(method = "largeValueSetAndCriteriaSizes")
  public void testBulkSQLUpdateWithLargeValueSetAndCriteriaList(
      int valueCount, int criteriaListSize) {
    Owner owner = this.createOwner();

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

    for (int i = 1; i <= valueCount; ++i) {
      this.createContent("c" + i, "content-" + i, owner);

      // We want every odd value to be unaffected, but we still want a fake update entry
      // for the query
      values.put("content-" + (i % 2 == 0 ? i : "X" + i), "update-" + i);
    }

    Map<String, Object> criteria = new HashMap<String, Object>();
    List<String> valueList = new LinkedList<String>();
    criteria.put("name", valueList);

    for (int i = 1; i <= criteriaListSize; ++i) {
      valueList.add("content-" + (i % 2 == 0 ? i : "X" + i));
    }

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

    testContentCurator.clear();

    for (int i = 1; i <= valueCount; ++i) {
      Content content = this.ownerContentCurator.getContentById(owner, "c" + i);

      if (i % 2 == 0) {
        assertEquals("update-" + i, content.getName());
      } else {
        assertEquals("content-" + i, content.getName());
      }
    }
  }