Class MutatesArgument<Argument,Type>
- java.lang.Object
-
- org.saynotobugs.confidence.quality.function.MutatesArgument<Argument,Type>
-
- All Implemented Interfaces:
Quality<java.util.function.Function<Argument,Type>>
public final class MutatesArgument<Argument,Type> extends java.lang.Object implements Quality<java.util.function.Function<Argument,Type>>
Qualityof a non-pureFunctionthat mutates its argument when called.Examples
The following test ensures the function
list->list:addadds an element to a givenListand returnstruewhen the list content has been changed.assertThat(list -> list::add, mutatesArgument( ArrayList::new, soIt(iterates("a")), when(maps("a", to(true)))));A common use case is testing mutation of Constructor arguments of mutable classes. Consider a
ListAppenderConsumerthat appends any value to the given list.assertThat(list -> new ListAppender(list), mutatesArgument( ArrayList::new, soIt(iterates("a")), when(consumerThatAccepts("a"))));
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AssessmentassessmentOf(java.util.function.Function<Argument,Type> candidate)Descriptiondescription()
-
-
-
Method Detail
-
assessmentOf
public Assessment assessmentOf(java.util.function.Function<Argument,Type> candidate)
- Specified by:
assessmentOfin interfaceQuality<Argument>
-
description
public Description description()
- Specified by:
descriptionin interfaceQuality<Argument>
-
-