Ejemplo n.º 1
0
  @Test
  public void testPrependToProtectedList() throws SyntaxException, InvalidTermException {

    Context context = new CompileTimeContext();

    // Create a protected resource.
    ListResource list = new ListResource();
    list = (ListResource) list.protect();

    Element value = StringProperty.getInstance("OK");

    Operation dml = Prepend.getInstance(null, list, value);

    Element result = context.executeDmlBlock(dml);

    // Check that the list argument has NOT been updated.
    assertTrue(list.size() == 0);

    // Verify that a copy has been made.
    assertTrue(result != list);

    // It must also be a list.
    assertTrue(result instanceof ListResource);

    // Verify that the new list has the correct value.
    Element element = ((ListResource) result).get(TermFactory.create(0));
    assertTrue(value == element);
  }
Ejemplo n.º 2
0
  @Test
  public void testPrependToList() throws SyntaxException, InvalidTermException {

    Context context = new CompileTimeContext();
    ListResource list = new ListResource();
    Element value = StringProperty.getInstance("OK");

    Operation dml = Prepend.getInstance(null, list, value);

    Element result = context.executeDmlBlock(dml);

    // Check that the list argument has been updated.
    assertTrue(list.size() == 1);
    Element element = list.get(TermFactory.create(0));
    assertTrue(value == element);

    // Verify that the same list is given as the result.
    assertTrue(result == list);
  }