org.unitils.mock.report.impl
Class ObservedInvocationsReport

java.lang.Object
  extended by org.unitils.mock.report.impl.ProxyInvocationsReport
      extended by org.unitils.mock.report.impl.ObservedInvocationsReport
Direct Known Subclasses:
DetailedObservedInvocationsReport

public class ObservedInvocationsReport
extends ProxyInvocationsReport

A view that displays the observed invocations and the location where they were invoked. The arguments are shown inline when the length is small enough, else the argument is named using the type (eg Person => person1).

Example:


 1.  mock.method1()) -> string1  ..... at MyTest.testMethod(MyTest.java:60)
 2.  mock.method1("bla", 4) -> null  ..... at MyTest.testMethod(MyTest.java:62)
 3.  mock.anotherMethod(myClass1)  ..... at MyTest.testMethod(MyTest.java:64)
 

Author:
Kenny Claes, Filip Neven, Tim Ducheyne

Nested Class Summary
 
Nested classes/interfaces inherited from class org.unitils.mock.report.impl.ProxyInvocationsReport
ProxyInvocationsReport.FormattedObject
 
Field Summary
 
Fields inherited from class org.unitils.mock.report.impl.ProxyInvocationsReport
MAX_INLINE_PARAMETER_LENGTH, OBJECT_FORMATTER_MAX_NR_ARRAY_OR_COLLECTION_ELEMENTS, OBJECT_FORMATTER_MAX_RECURSION_DEPT, objectFormatter, testedObjectFieldValuesAndNames
 
Constructor Summary
ObservedInvocationsReport(Object testedObject)
           
 
Method Summary
 String createReport(List<ObservedInvocation> observedInvocations)
          Creates a string representation of the given invocations as described in the class javadoc.
protected  String formatMockName(ObservedInvocation observedInvocation)
           
protected  String formatObservedInvocation(ObservedInvocation observedInvocation, List<ProxyInvocationsReport.FormattedObject> currentLargeObjects, Map<Object,ProxyInvocationsReport.FormattedObject> allLargeObjects, Map<Class<?>,Integer> largeObjectNameIndexes)
          Creates a string representation of the given invocation.
 
Methods inherited from class org.unitils.mock.report.impl.ProxyInvocationsReport
createLargeValueName, formatInvocationIndex, formatInvokedAt, formatObject, formatValue, getFieldValuesAndNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObservedInvocationsReport

public ObservedInvocationsReport(Object testedObject)
Method Detail

createReport

public String createReport(List<ObservedInvocation> observedInvocations)
Creates a string representation of the given invocations as described in the class javadoc.

Parameters:
observedInvocations - The invocations for which to create a report, not null
Returns:
The string representation, not null

formatObservedInvocation

protected String formatObservedInvocation(ObservedInvocation observedInvocation,
                                          List<ProxyInvocationsReport.FormattedObject> currentLargeObjects,
                                          Map<Object,ProxyInvocationsReport.FormattedObject> allLargeObjects,
                                          Map<Class<?>,Integer> largeObjectNameIndexes)
Creates a string representation of the given invocation. If arguments and result values are small enough, they are displayed inline, else the value is replaced by a name generated by the ProxyInvocationsReport.createLargeValueName(java.lang.Class, java.util.Map, java.lang.Integer>) method.

Parameters:
observedInvocation - The invocation to format, not null
currentLargeObjects - The current the large values, not null
allLargeObjects - All large values per value, not null
largeObjectNameIndexes - The current indexes to use for the large value names (per value type), not null
Returns:
The string representation, not null

formatMockName

protected String formatMockName(ObservedInvocation observedInvocation)


Copyright © 2011. All Rights Reserved.