Package h07.graph
Class PathImplTest
- java.lang.Object
-
- h07.util.TestClass
-
- h07.graph.PathImplTest
-
public class PathImplTest extends TestClass
Tests for classPathImpl
.
Depends onTemplateTests.PathTemplateTest
andTemplateTests.TraverserTemplateTest
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
PathImplTest.TraverserTest
Tests for theTraverser
returned byPathImpl.traverser()
.-
Nested classes/interfaces inherited from class h07.util.TestClass
TestClass.MissingMemberException
-
-
Field Summary
Fields Modifier and Type Field Description private TemplateTests.TraverserTemplateTest
_traverser
Instance ofTemplateTests.TraverserTemplateTest
Method
concat
Method
object forPath.concat(V, A)
Method
iterator
Method
object forPath.iterator()
Method
of1
Method
object forPath.of(V)
Method
of2
Method
object forPath.of(V, A, V)
Method
of3
Method
object forPath.of(V, A, V, A, V)
private TemplateTests.PathTemplateTest
path
Instance ofTemplateTests.PathTemplateTest
Method
traverser
Method
object forPath.traverser()
-
Fields inherited from class h07.util.TestClass
classDescriptor, className, constructor, fields, methods, RANDOM
-
-
Constructor Summary
Constructors Constructor Description PathImplTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
newInstance(Object... params)
Returns a newPathImpl
object.void
testConcat(Character[] nodes, int[] arcWeights)
Tests forPathImpl.concat(Object, Object)
.void
testDefinition()
Tests the definition ofPathImpl
.void
testIterator()
Tests forPathImpl.iterator()
.-
Methods inherited from class h07.util.TestClass
getClassForName, getFieldByCriteria, getFieldByName, getMethodByCriteria, getMethodByName, getMethodSignature, invokeExpectingException, newInstanceExpectingException, testInstance
-
-
-
-
Field Detail
-
traverser
public final Method traverser
Method
object forPath.traverser()
-
concat
public final Method concat
Method
object forPath.concat(V, A)
-
iterator
public final Method iterator
Method
object forPath.iterator()
-
of1
public final Method of1
Method
object forPath.of(V)
-
of2
public final Method of2
Method
object forPath.of(V, A, V)
-
of3
public final Method of3
Method
object forPath.of(V, A, V, A, V)
-
path
private final TemplateTests.PathTemplateTest path
Instance ofTemplateTests.PathTemplateTest
-
_traverser
private final TemplateTests.TraverserTemplateTest _traverser
Instance ofTemplateTests.TraverserTemplateTest
-
-
Method Detail
-
testDefinition
@Test public void testDefinition()
Tests the definition ofPathImpl
.- Asserts that the class...
- is package-private
- is not abstract
- is generic and has the type parameters V and A
- either extends
AbstractPath
or implementsPath
directly
- Specified by:
testDefinition
in classTestClass
- Asserts that the class...
-
testConcat
@ParameterizedTest @ArgumentsSource(PathProvider.class) public void testConcat(Character[] nodes, int[] arcWeights) throws ReflectiveOperationException
Tests forPathImpl.concat(Object, Object)
. RequiresPathImpl.traverser()
.
Asserts that the object returned by the tested method is a newPathImpl
object. Further asserts that the order and weights of nodes didn't change and the new node was appended to the end. Also asserts that the method throws aNullPointerException
if invoked withnull
.- Parameters:
nodes
- an array of nodes (supplied by the arguments provider)arcWeights
- an array of weights from a node at indexi
to the one at indexi + 1
(supplied by the arguments provider)- Throws:
ReflectiveOperationException
- if any invocation fails
-
testIterator
@Test public void testIterator() throws ReflectiveOperationException
Tests forPathImpl.iterator()
.
Asserts that the iterator returned by the tested method iterates through all given nodes and throws aNoSuchElementException
when the iterator has reached its end.- Throws:
ReflectiveOperationException
- if any invocation fails
-
newInstance
public Object newInstance(Object... params)
Returns a newPathImpl
object.
It is necessary to overrideTestClass.newInstance(Object...)
because no constructors have been specified by the assignment, so usingPath.of(V)
,Path.of(V, A, V)
orPath.of(V, A, V, A, V)
is the way to go.- Overrides:
newInstance
in classTestClass
- Parameters:
params
- the parameters to supply to the constructor, either 1, 3 or 5 parameters as specified by the static initializer methods ofPath
- Returns:
- a new
PathImpl
instance
-
-