Skip to content

Commit

Permalink
Fixed sonar-identified potential NPEs (#115)
Browse files Browse the repository at this point in the history
* Fixed sonar-identifed potential NPEs

* doc fix
  • Loading branch information
therealryan authored Oct 12, 2022
1 parent 5d79d2e commit b84c9a6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.Optional;

import com.mastercard.test.flow.Interaction;
Expand Down Expand Up @@ -185,9 +186,12 @@ private static void populate( Assertion asrt, InteractionData id ) {
// interactions (e.g.: you might be able to capture the data that comes out of
// the system). Hence we need to recurse down the interaction structure and
// populate the whole tree underneath
for( InteractionData child : id.children ) {
asrt.assertChildren( i -> matches( i, child ) )
.forEach( ca -> populate( ca, child ) );
}
Optional.ofNullable( id )
.map( f -> f.children )
.map( List::stream )
.ifPresent( s -> s
.forEach( child -> asrt
.assertChildren( i -> matches( i, child ) )
.forEach( ca -> populate( ca, child ) ) ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ public MutableInteraction( MutableInteraction parent ) {
*/
public MutableInteraction( MutableInteraction parent, Interaction src ) {
this.parent = parent;
request( Optional.ofNullable( src )
.map( Interaction::request )
.orElse( null ) );
request( src.request() );
responder = src.responder();
response( Optional.ofNullable( src )
.map( Interaction::response )
.orElse( null ) );
response( src.response() );
tags.addAll( src.tags() );
src.children().forEach( c -> children.add( new MutableInteraction( this, c ) ) );
}
Expand Down
2 changes: 1 addition & 1 deletion doc/src/main/markdown/further.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ You can use [`Replay.isActive()`][Replay.isActive()] in your assertion component

<!-- code_link_start -->

[Replay.isActive()]: ../../../../assert/assert-core/src/main/java/com/mastercard/test/flow/assrt/Replay.java#L40-L47,40-47
[Replay.isActive()]: ../../../../assert/assert-core/src/main/java/com/mastercard/test/flow/assrt/Replay.java#L41-L48,41-48

<!-- code_link_end -->

Expand Down

0 comments on commit b84c9a6

Please sign in to comment.