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

SUT highlight #545

Merged
merged 3 commits into from
Sep 19, 2023
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 @@ -621,6 +621,9 @@ private void finaliseReport( Flow flow,
reportUpdates.add( d -> executionFailures.stream()
.map( e -> error( LogEvent.stackTrace( e ) ) )
.forEach( d.logs::add ) );
reportUpdates.add( d -> systemUnderTest.stream()
.map( Actor::name )
.forEach( d.exercised::add ) );
report( w -> w.with( flow, reportUpdates.stream()
.reduce( d -> {
// no-op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.jupiter.api.Test;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.mastercard.test.flow.Actor;
import com.mastercard.test.flow.assrt.AbstractFlocessor.State;
import com.mastercard.test.flow.report.Reader;
import com.mastercard.test.flow.report.data.Entry;
Expand Down Expand Up @@ -285,4 +286,24 @@ void skipTagging() {
FlowData fd = r.detail( ie );
assertTrue( fd.tags.contains( "SKIP" ), fd.tags.toString() );
}

/**
* Shows that the {@link Actor}s under test are recorded to the report
*/
@Test
void exercised() {
TestFlocessor tf = new TestFlocessor( "exercised", TestModel.abc() )
.system( State.FUL, B )
.reporting( QUIETLY )
.behaviour( assrt -> {
// no assertions made
} );
tf.execute();

Reader r = new Reader( tf.report() );
Index index = r.read();
Entry ie = index.entries.get( 0 );
FlowData fd = r.detail( ie );
assertEquals( "[B]", fd.exercised.toString() );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public IndexedFlowData( Flow flow,
}

if( !desiredBases.isEmpty() ) {
// keep track of the missing ones. If those get added to the rpeort later we'll
// keep track of the missing ones. If those get added to the report later we'll
// want to update this flow to point at them
missingBases.put( flow, desiredBases );
}
Expand Down Expand Up @@ -238,6 +238,7 @@ public IndexedFlowData( Flow flow,
flow.residue()
.map( r -> new ResidueData( r.name(), r, null, null ) )
.collect( toList() ),
new TreeSet<>(),
new ArrayList<>() );
update();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ public class FlowData {
@JsonProperty("residue")
public final List<ResidueData> residue;

/**
* The names of the actors that are in the system under test
*/
@JsonProperty("exercised")
public final Set<String> exercised;

/**
* A record of system events that happened when the {@link Flow} was exercised
*/
Expand All @@ -83,6 +89,7 @@ public class FlowData {
* @param context A map from {@link Context#name()} to {@link Context}
* object. We'll leave jackson to serialise the contents
* @param residue A map from {@link Residue} name to residue data
* @param exercised The names of the actors that are in the system under test
* @param logs A record of system events that happened when the
* {@link Flow} was exercised
*/
Expand All @@ -96,6 +103,7 @@ public FlowData(
@JsonProperty("root") InteractionData root,
@JsonProperty("context") Map<String, Object> context,
@JsonProperty("residue") List<ResidueData> residue,
@JsonProperty("exercised") Set<String> exercised,
@JsonProperty("logs") List<LogEvent> logs ) {
this.description = description;
this.tags = new TreeSet<>( tags );
Expand All @@ -106,6 +114,7 @@ public FlowData(
this.root = root;
this.context = new TreeMap<>( context );
this.residue = new ArrayList<>( residue );
this.exercised = new TreeSet<>( exercised );
this.logs = logs;
}

Expand All @@ -120,6 +129,6 @@ public FlowData withBasis( String b ) {
return new FlowData( description, tags, motivation, trace,
b,
dependencies, root, context,
residue, logs );
residue, exercised, logs );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ void write() throws Exception {
+ " \"full\" : null,\n"
+ " \"masked\" : null\n"
+ " } ],\n"
+ " \"exercised\" : [ ],\n"
+ " \"logs\" : [ ]\n"
+ "}\n"
+ " // END_JSON_DATA",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('DetailComponent', () => {
context: {},
residue: [],
root: empty_interaction,
exercised: [],
logs: [],
};
fixture.detectChanges();
Expand Down Expand Up @@ -135,7 +136,7 @@ class StubLogView {
template: ''
})
class StubFlowSequence {
@Input() sequence: SequenceData = { entity: [], item: [] };
@Input() sequence: SequenceData = { entity: [], exercised: [], item: [] };
}

@Component({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class DetailComponent implements OnInit {
rsdFailed: boolean = false;
noDeps: boolean = true;
singleDependency: string = "";
sequence: SequenceData = { entity: [], item: [] };
sequence: SequenceData = { entity: [], exercised: [], item: [] };
options: Options = new Options();
tabIndex = 0;

Expand Down Expand Up @@ -159,7 +159,7 @@ export class DetailComponent implements OnInit {
export function toSequence(flow: Flow): SequenceData {
const [names, indices] = extractActors(flow.root, [], new Map());
const actions = extractTransmissions(flow.root, indices, []);
return { entity: names, item: actions };
return { entity: names, exercised: flow.exercised, item: actions };
}

function extractActors(ntr: Interaction, names: string[], indices: Map<string, number>): [string[], Map<string, number>] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
z-index: 1;
}

.sut_entity {
background-color: lightgray;
border-radius: 10px 10px 0 0;
margin-right: 5%;
margin-left: 5%;
}

app-msg-search-input {
float: right;
position: relative;
Expand All @@ -29,9 +36,16 @@ app-msg-search-input {
}

.line {
border-left: 2px solid #DDD;
bottom: 0;
position: absolute;
top: 0;
z-index: 0;
}

.def_line {
border-left: 2px solid #DDD;
}

.sut_line {
border-left: 2px solid #888;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
<div class="header">
<div class="entity" *ngFor="let entity of sequence.entity; index as i;"
[ngStyle]="columnStyle( i, sequence.entity.length )">
{{entity}}
<div [ngClass]="sequence.exercised.includes( entity ) ? 'sut_entity': 'def_entity'">
{{entity}}
</div>
</div>
<app-msg-search-input></app-msg-search-input>
</div>
<div class="body">
<div class="line" *ngFor="let entity of sequence.entity; index as i;"
[ngStyle]="leftStyle( i, sequence.entity.length )">
[ngStyle]="leftStyle( i, sequence.entity.length )"
[ngClass]="sequence.exercised.includes( entity ) ? 'sut_line': 'def_line'">
</div>
<div *ngFor="let item of sequence.item">
<app-seq-action *ngIf="isAction(item)" [entity]="sequence.entity" [action]="item"></app-seq-action>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { TxSelectionService } from '../tx-selection.service';
})
export class FlowSequenceComponent implements OnInit {

@Input() sequence: SequenceData = { entity: [], item: [] };
@Input() sequence: SequenceData = { entity: [], exercised: [], item: [] };

constructor(
private txSelect: TxSelectionService) {
Expand Down Expand Up @@ -48,6 +48,8 @@ export class FlowSequenceComponent implements OnInit {
export interface SequenceData {
/** The column headers in the diagram */
entity: string[];
/** The column headers that are in the system under test */
exercised: string[];
/** The things that happen in the sequence */
item: Array<Action | Note | Section>;
}
Expand Down Expand Up @@ -87,5 +89,5 @@ export function rightStyle(pos: number, count: number): Object {
* @returns The input ration, but as a percentage string to 1 decimal place
*/
function percentage(ratio: number): string {
return (Math.round(ratio * 1000) / 10) + '%';
return "calc(" + (Math.round(ratio * 1000) / 10) + "% - 1px )";
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ function lines(component: HTMLElement): string[] {
function highlit(component: HTMLElement): string[] {
let spans: HTMLElement[] = Array.from(component
.querySelectorAll("span"));
console.log(spans);
return spans
.filter(e => e.classList.contains("hovered")
|| e.classList.contains("same_value"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#search_toggle {
float: right;
border-left: 2px solid #888;
background-color: white;
}

mat-icon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<mat-icon svgIcon="{{showInput?'clear':'search'}}"></mat-icon>
</div>
<div *ngIf="showInput">
<mat-form-field class="example-full-width" appearance="fill">
<mat-form-field appearance="fill">
<mat-label>Message search</mat-label>
<input type="search" id="search_input" matInput #input [ngModel]="value"
(ngModelChange)="onSearchChange($event)" name="search_term" autocomplete="new-search_term">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, OnInit, Input } from '@angular/core';
import { BasisFetchService } from '../basis-fetch.service';
import { leftStyle, rightStyle } from '../flow-sequence/flow-sequence.component';
import { MsgSearchService } from '../msg-search.service';
import { TxSelectionService } from '../tx-selection.service';
import { Transmission, isTransmission, empty_transmission } from '../types';
Expand Down Expand Up @@ -179,3 +178,30 @@ export const empty_action: Action = {
tags: [],
transmission: empty_transmission
};


/**
* @param pos The column index
* @param count The number of columns
* @returns The style data to apply to things that extends to the right of the column
*/
function leftStyle(pos: number, count: number): Object {
return { "margin-left": percentage((pos + 0.5) / count) };
}

/**
* @param pos The column index
* @param count The number of columns
* @returns The style data to apply to things that extends to the left of the column
*/
function rightStyle(pos: number, count: number): Object {
return { "margin-right": percentage((count - pos - 0.5) / count) };
}

/**
* @param ratio A number in range 0-1
* @returns The input ration, but as a percentage string to 1 decimal place
*/
function percentage(ratio: number): string {
return (Math.round(ratio * 1000) / 10) + '%';
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class SystemDiagramComponent implements OnInit {
this.refreshEdges();
});
filter.onUpdate(() => {
console.log("filter.onUpdate", this.hideFilteredActors);
if (this.hideFilteredActors) {
this.refreshEdges();
}
Expand Down Expand Up @@ -100,7 +99,6 @@ export class SystemDiagramComponent implements OnInit {
* Called when a flow has been loaded, recalculates all the edges in the system
*/
private refreshEdges(): void {
console.log("refreshEdges", this.hideFilteredActors);

let requests: { [key: string]: { [key: string]: number } } = {};
this.edges = [];
Expand Down
4 changes: 4 additions & 0 deletions report/report-ng/projects/report/src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export interface Flow {
residue: Residue[];
dependencies: Dependencies;
root: Interaction;
exercised: string[];
logs: LogEvent[];
}

Expand All @@ -167,6 +168,8 @@ export function isFlow(data: any): data is Flow {
&& isInteraction(data.root)
&& Array.isArray(data.residue)
&& data.residue.every(isResidue)
&& Array.isArray(data.exercised)
&& data.exercised.every((item: any) => typeof item === 'string')
&& Array.isArray(data.logs)
&& data.logs.every(isLogEvent);
;
Expand Down Expand Up @@ -464,5 +467,6 @@ export const empty_flow: Flow = {
context: {},
residue: [],
root: empty_interaction,
exercised: [],
logs: [],
};