Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Squashed some low-hanging mutants #748

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void fluency() {
assertSame( tf, tf.applicators() );
assertSame( tf, tf.checkers() );
assertSame( tf, tf.logs( null ) );
assertSame( tf, tf.autonomous() );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import static com.mastercard.test.flow.assrt.AbstractFlocessorTest.copypasta;
import static com.mastercard.test.flow.assrt.TestModel.Actors.B;
import static com.mastercard.test.flow.assrt.TestModel.Actors.C;
import static com.mastercard.test.flow.assrt.TestModel.Actors.D;
import static com.mastercard.test.flow.assrt.TestModel.Actors.E;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
Expand Down Expand Up @@ -90,12 +92,12 @@ void extraConsequests() {
}

/**
* Adding assertions on the grandchild of the entrypoint
* Adding assertions on distant descendants of the entrypoint
*/
@Test
void assertGrandchild() {
TestFlocessor tf = new TestFlocessor( "assertGrandchild", TestModel.abc() )
.system( State.LESS, B, C )
void assertDescendant() {
TestFlocessor tf = new TestFlocessor( "assertDescendant", TestModel.abcde() )
.system( State.LESS, B, C, D, E )
.behaviour( asrt -> {
// everything goes well at the entrypoint
asrt.actual()
Expand All @@ -105,23 +107,23 @@ void assertGrandchild() {
// and we've got a window into the system internals, so we can add intra-system
// assertions too
asrt.assertDownstream()
.filter( a -> a.expected().responder() == C )
.filter( a -> a.expected().responder() == E )
.forEach( a -> a.actual().request( a.expected().request().content() ) );
} );

tf.execute();

assertEquals( copypasta(
"COMPARE abc []",
"com.mastercard.test.flow.assrt.TestModel.abc(TestModel.java:_) A->B [] request",
"COMPARE abcde []",
"com.mastercard.test.flow.assrt.TestModel.abcde(TestModel.java:_) A->B [] request",
" | A request to B | A request to B |",
"",
"COMPARE abc []",
"com.mastercard.test.flow.assrt.TestModel.abc(TestModel.java:_) B->C [] request",
" | B request to C | B request to C |",
"COMPARE abcde []",
"com.mastercard.test.flow.assrt.TestModel.abcde(TestModel.java:_) D->E [] request",
" | D request to E | D request to E |",
"",
"COMPARE abc []",
"com.mastercard.test.flow.assrt.TestModel.abc(TestModel.java:_) A->B [] response",
"COMPARE abcde []",
"com.mastercard.test.flow.assrt.TestModel.abcde(TestModel.java:_) A->B [] response",
" | B response to A | B response to A |" ),
copypasta( tf.events() ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ private static void test( State state, Actor auton, String... expect ) {
if( auton != null ) {
tf.autonomous( auton );
}
else {
// show that calls to autonomous overwrites the previous call
tf.autonomous( Actors.B );
tf.autonomous();
}

tf.execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public void filtering() {
events.add( "filtering" );
}

@Override
public void dependencies() {
events.add( "dependencies" );
}

@Override
public void ordering() {
events.add( "ordering" );
Expand Down Expand Up @@ -88,6 +93,7 @@ public void flowComplete( Flow flow ) {

assertEquals( copypasta(
"filtering",
"dependencies",
"ordering",
"flow : abc []",
"context : TestContext",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,29 @@ public static Model abc() {
}

/**
* @return A model with a single flow, calling from A to B to C
* @return A model with a single flow, calling from A to B to C to D to E
*/
public static Model abcde() {
Flow abc = abc().flows().findFirst().get();

Flow abcde = Deriver.build( abc, flow -> flow
.meta( data -> data
.description( "abcde" ) )
.addCall( i -> i.responder() == Actors.C, c -> c
.to( Actors.D )
.request( new Text( "C request to D" ) )
.call( d -> d
.to( Actors.E )
.request( new Text( "D request to E" ) )
.response( new Text( "E response to D" ) ) )
.response( new Text( "D response to C" ) ) ) );

return new Mdl().withFlows( abcde );
}

/**
* @return A model with a two flows, both calling from A to B to C, and one
* being a child of the other
*/
public static Model abcWithChild() {
Flow abc = Creator.build( flow -> flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TailTest {
}

private static final Tail LOG_TAIL = new Tail( LOG_PATH,
"^(?<level>[A-Z]+) (?<time>\\d+) (?<source>[a-z]+)" );
"^(?<level>[A-Z]+) \\[\\w+\\] (?<time>\\d+) (?<source>[a-z]+)" );

/**
* Exercises extracting content from a file that grows as {@link Flow}s are
Expand All @@ -41,44 +41,44 @@ void tail() {
Flow a = new Flw( "a []" );
Flow b = new Flw( "b []" );

log( "INFO 001 foosrc This line is before the tail started" );
log( "INFO [main] 001 foosrc This line is before the tail started" );

LOG_TAIL.start( a );

log( "INFO 002 foosrc This line is after the tail started",
"WARN 003 barsrc there's about to be some multline content!",
log( "INFO [main] 002 foosrc This line is after the tail started",
"WARN [thread1] 003 barsrc there's about to be some multline content!",
" Here is content from the previous line's event!",
" and there's more!",
"INFO 004 foosrc here's another event" );
"INFO [thread2] 004 foosrc here's another event" );

LOG_TAIL.start( b );

log( " here is more content from the previous event!",
"TRACE 005 bazsrc This event will be shared by both flows" );
"TRACE [thread1] 005 bazsrc This event will be shared by both flows" );

Stream<LogEvent> ae = LOG_TAIL.end( a );

log( "TRACE 006 bazsrc This event is just for b" );
log( "TRACE [main] 006 bazsrc This event is just for b" );

Stream<LogEvent> be = LOG_TAIL.end( b );

log( "ERROR 007 bazsrc No-one sees this one" );
log( "ERROR [main] 007 bazsrc No-one sees this one" );

Assertions.assertEquals( ""
+ "INFO/foosrc/002/This line is after the tail started\n"
+ "WARN/barsrc/003/there's about to be some multline content!\n"
+ "INFO/foosrc/002/[main] This line is after the tail started\n"
+ "WARN/barsrc/003/[thread1] there's about to be some multline content!\n"
+ " Here is content from the previous line's event!\n"
+ " and there's more!\n"
+ "INFO/foosrc/004/here's another event\n"
+ "INFO/foosrc/004/[thread2] here's another event\n"
+ " here is more content from the previous event!\n"
+ "TRACE/bazsrc/005/This event will be shared by both flows",
+ "TRACE/bazsrc/005/[thread1] This event will be shared by both flows",
ae.map( e -> String.format( "%s/%s/%s/%s", e.level, e.source, e.time, e.message ) )
.collect( Collectors.joining( "\n" ) ) );

Assertions.assertEquals( ""
+ "?/?/?/ here is more content from the previous event!\n"
+ "TRACE/bazsrc/005/This event will be shared by both flows\n"
+ "TRACE/bazsrc/006/This event is just for b",
+ "TRACE/bazsrc/005/[thread1] This event will be shared by both flows\n"
+ "TRACE/bazsrc/006/[main] This event is just for b",
be.map( e -> String.format( "%s/%s/%s/%s", e.level, e.source, e.time, e.message ) )
.collect( Collectors.joining( "\n" ) ) );
}
Expand Down
Loading