// @formatter:on
  @Test
  public void
      gradeForResourceDemandingInternalActionEvaluableExpressionEvaluableExpressionFitnessFunctionBlackboardView() {
    final AbstractionAndPrecisionFitnessFunction function =
        new AbstractionAndPrecisionFitnessFunction();
    final ResourceDemandingInternalAction nullRdia = null;
    final EvaluableExpression expression = mock(EvaluableExpression.class);
    final EvaluableExpressionFitnessFunctionBlackboardView blackboardView =
        mock(EvaluableExpressionFitnessFunctionBlackboardView.class);
    ThrowingMethod method =
        () -> {
          function.gradeFor(nullRdia, expression, blackboardView);
        };
    assertThat(
        "Resource Demanding Internal Action must not be null.",
        method,
        throwsException(NullPointerException.class));

    final ResourceDemandingInternalAction rdia =
        RESOURCE_DEMANDING_INTERNAL_ACTION_FACTORY.getOne();
    method =
        () -> {
          function.gradeFor(rdia, null, blackboardView);
        };
    assertThat(
        "Evaluable Expression must not be null.",
        method,
        throwsException(NullPointerException.class));

    method =
        () -> {
          function.gradeFor(rdia, expression, null);
        };
    assertThat(
        "Blackboard view must not be null.", method, throwsException(NullPointerException.class));

    Set<ResourceDemandMeasurementResult> results = new HashSet<>();
    results.add(new ResourceDemandMeasurementResult(2.0));
    final EvaluableExpression expression2 = mock(EvaluableExpression.class);
    given(blackboardView.getMeasurementResultsFor(rdia)).willReturn(results);
    given(expression.evaluate(any())).willReturn(2.0);
    given(expression2.evaluate(any())).willReturn(10.32);
    assertThat(
        function.gradeFor(rdia, expression, blackboardView),
        is(lessThan(function.gradeFor(rdia, expression2, blackboardView))));

    results = new HashSet<>();
    results.add(new ResourceDemandMeasurementResult(2.0));
    results.add(new ResourceDemandMeasurementResult(20.32));
    given(blackboardView.getMeasurementResultsFor(rdia)).willReturn(results);
    assertThat(
        function.gradeFor(rdia, expression2, blackboardView),
        is(lessThan(function.gradeFor(rdia, expression, blackboardView))));

    results = new HashSet<>();
    given(blackboardView.getMeasurementResultsFor(rdia)).willReturn(results);
    given(expression.evaluate(any())).willReturn(2.0);
    given(expression2.evaluate(any())).willReturn(10.32);
    assertThat(function.gradeFor(rdia, expression, blackboardView), is(Double.POSITIVE_INFINITY));
  }
  // @formatter:on
  @Test
  public void
      gradeForSeffBranchEvaluableExpressionEvaluableExpressionFitnessFunctionBlackboardView() {
    final AbstractionAndPrecisionFitnessFunction function =
        new AbstractionAndPrecisionFitnessFunction();
    final SeffBranch nullBranch = null;
    final EvaluableExpression expression = mock(EvaluableExpression.class);
    final EvaluableExpressionFitnessFunctionBlackboardView blackboardView =
        mock(EvaluableExpressionFitnessFunctionBlackboardView.class);
    ThrowingMethod method =
        () -> {
          function.gradeFor(nullBranch, expression, blackboardView);
        };
    assertThat(
        "Seff branch must not be null.", method, throwsException(NullPointerException.class));

    final SeffBranch branch = SEFF_BRANCH_FACTORY.getOne();
    method =
        () -> {
          function.gradeFor(branch, null, blackboardView);
        };
    assertThat(
        "Evaluable Expression must not be null.",
        method,
        throwsException(NullPointerException.class));

    method =
        () -> {
          function.gradeFor(branch, expression, null);
        };
    assertThat(
        "Blackboard view must not be null.", method, throwsException(NullPointerException.class));

    Set<BranchDecisionMeasurementResult> results = new HashSet<>();
    results.add(new BranchDecisionMeasurementResult(2));
    final EvaluableExpression expression2 = mock(EvaluableExpression.class);
    given(blackboardView.getMeasurementResultsFor(branch)).willReturn(results);
    given(expression.evaluate(any())).willReturn(2.0);
    given(expression2.evaluate(any())).willReturn(10.32);
    assertThat(
        function.gradeFor(branch, expression, blackboardView),
        is(lessThan(function.gradeFor(branch, expression2, blackboardView))));

    results = new HashSet<>();
    results.add(new BranchDecisionMeasurementResult(2));
    results.add(new BranchDecisionMeasurementResult(20));
    given(blackboardView.getMeasurementResultsFor(branch)).willReturn(results);
    assertThat(
        function.gradeFor(branch, expression2, blackboardView),
        is(lessThan(function.gradeFor(branch, expression, blackboardView))));

    results = new HashSet<>();
    given(blackboardView.getMeasurementResultsFor(branch)).willReturn(results);
    given(expression.evaluate(any())).willReturn(2.0);
    given(expression2.evaluate(any())).willReturn(10.32);
    assertThat(function.gradeFor(branch, expression, blackboardView), is(Double.POSITIVE_INFINITY));
  }
  // @formatter:on
  @Test
  public void
      gradeForExternalCallParameterEvaluableExpressionEvaluableExpressionFitnessFunctionBlackboardView() {
    final AbstractionAndPrecisionFitnessFunction function =
        new AbstractionAndPrecisionFitnessFunction();
    final ExternalCallParameter nullParameter = null;
    final EvaluableExpression expression = mock(EvaluableExpression.class);
    final EvaluableExpressionFitnessFunctionBlackboardView blackboardView =
        mock(EvaluableExpressionFitnessFunctionBlackboardView.class);
    ThrowingMethod method =
        () -> {
          function.gradeFor(nullParameter, expression, blackboardView);
        };
    assertThat(
        "External Call Parameter must not be null.",
        method,
        throwsException(NullPointerException.class));

    final ExternalCallParameter parameter = EXTERNAL_CALL_PARAMETER_FACTORY.getOne();
    method =
        () -> {
          function.gradeFor(parameter, null, blackboardView);
        };
    assertThat(
        "Evaluable Expression must not be null.",
        method,
        throwsException(NullPointerException.class));

    method =
        () -> {
          function.gradeFor(parameter, expression, null);
        };
    assertThat(
        "Blackboard view must not be null.", method, throwsException(NullPointerException.class));

    Set<ParameterChangeMeasurementResult> results = new HashSet<>();
    ParameterChangeMeasurementResult parameterChangeResult =
        mock(ParameterChangeMeasurementResult.class);
    given(parameterChangeResult.getCount()).willReturn(2);
    results.add(parameterChangeResult);
    final EvaluableExpression expression2 = mock(EvaluableExpression.class);
    given(blackboardView.getMeasurementResultsFor(parameter)).willReturn(results);
    given(expression.evaluate(any())).willReturn(2.0);
    given(expression2.evaluate(any())).willReturn(10.32);
    assertThat(
        function.gradeFor(parameter, expression, blackboardView),
        is(lessThan(function.gradeFor(parameter, expression2, blackboardView))));

    results = new HashSet<>();
    parameterChangeResult = mock(ParameterChangeMeasurementResult.class);
    given(parameterChangeResult.getCount()).willReturn(2);
    results.add(parameterChangeResult);
    final ParameterChangeMeasurementResult parameterChangeResult2 =
        mock(ParameterChangeMeasurementResult.class);
    given(parameterChangeResult2.getCount()).willReturn(22);
    results.add(parameterChangeResult2);
    given(blackboardView.getMeasurementResultsFor(parameter)).willReturn(results);
    assertThat(
        function.gradeFor(parameter, expression2, blackboardView),
        is(lessThan(function.gradeFor(parameter, expression, blackboardView))));

    results = new HashSet<>();
    given(blackboardView.getMeasurementResultsFor(parameter)).willReturn(results);
    given(expression.evaluate(any())).willReturn(2.0);
    given(expression2.evaluate(any())).willReturn(10.32);
    assertThat(
        function.gradeFor(parameter, expression, blackboardView), is(Double.POSITIVE_INFINITY));
  }