Exemple #1
0
 @Test
 public void testGetChildren_5() {
   CompositeFunction compositeFunction = new CompositeFunction();
   Subtract sub = new Subtract();
   compositeFunction.addFunction(sub);
   sub.addFunction(new Gaussian());
   FunctionModelRoot modelRoot = new FunctionModelRoot(compositeFunction, provider);
   assertTreeLooksLike(
       modelRoot, Node.SUBTACT(Node.GAUSSIAN, Node.SET_FUNCTION), Node.ADD_NEW_FUNCTION);
 }
Exemple #2
0
  @Test
  public void testGetSetFunctionModel() {
    CompositeFunction compositeFunction = new CompositeFunction();
    Subtract sub = new Subtract();
    sub.addFunction(new Gaussian());
    compositeFunction.addFunction(sub);
    FunctionModelRoot modelRoot = new FunctionModelRoot(compositeFunction, provider);
    assertTreeLooksLike(
        modelRoot, Node.SUBTACT(Node.GAUSSIAN, Node.SET_FUNCTION), Node.ADD_NEW_FUNCTION);

    SetFunctionModel[] setFunctionModels = modelRoot.getSetFunctionModel(sub, 1);
    assertEquals(1, setFunctionModels.length);
    assertTrue(sub == setFunctionModels[0].getParent());
    assertEquals(1, setFunctionModels[0].getFunctionIndex());

    assertEquals(0, modelRoot.getSetFunctionModel(sub, 0).length);
    assertEquals(0, modelRoot.getSetFunctionModel(new Subtract(), 0).length);
    assertEquals(0, modelRoot.getSetFunctionModel(new Subtract(), 1).length);
    assertEquals(0, modelRoot.getSetFunctionModel(new Add(), 0).length);
  }