From 559075c04d0bdcb5988876bad3d132e2ab83075d Mon Sep 17 00:00:00 2001 From: eostermueller Date: Fri, 6 Nov 2020 13:32:14 -0600 Subject: [PATCH] #30 is primitive but working --- .../src/main/web/src/app/model/workload.ts | 12 +++++- .../services/workload-change.service.spec.ts | 16 -------- .../app/services/workload-change.service.ts | 18 --------- .../src/main/web/src/app/use-case.service.ts | 1 - .../src/app/use-cases/use-cases.component.ts | 18 +++++++-- .../workload-key/workload-key.component.html | 8 ++++ .../workload-key/workload-key.component.ts | 1 + .../workload-selection.html | 2 +- .../snail4j/workload/model/UseCases.java | 8 ++++ .../model/json/DefaultSerializationUtil.java | 3 ++ .../model/json/JsonSerializationTest.java | 39 +++++++++++++++---- 11 files changed, 77 insertions(+), 49 deletions(-) delete mode 100644 frontend/src/main/web/src/app/services/workload-change.service.spec.ts delete mode 100644 frontend/src/main/web/src/app/services/workload-change.service.ts diff --git a/frontend/src/main/web/src/app/model/workload.ts b/frontend/src/main/web/src/app/model/workload.ts index 695d9c3..c102990 100644 --- a/frontend/src/main/web/src/app/model/workload.ts +++ b/frontend/src/main/web/src/app/model/workload.ts @@ -1,3 +1,11 @@ export class Workload { - useCases: any[] = new Array(); - } \ No newline at end of file + + useCases: any[] = new Array(); + + /** + * 0 = end user selected workload using check boxes and radio buttons + * 1 = clear text json workload key + * 2 = encrypted version of above key. + */ + origin: number = 0; +} \ No newline at end of file diff --git a/frontend/src/main/web/src/app/services/workload-change.service.spec.ts b/frontend/src/main/web/src/app/services/workload-change.service.spec.ts deleted file mode 100644 index 100b152..0000000 --- a/frontend/src/main/web/src/app/services/workload-change.service.spec.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { TestBed } from '@angular/core/testing'; - -import { WorkloadChangeService } from './workload-change.service'; - -describe('WorkloadChangeService', () => { - let service: WorkloadChangeService; - - beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(WorkloadChangeService); - }); - - it('should be created', () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/frontend/src/main/web/src/app/services/workload-change.service.ts b/frontend/src/main/web/src/app/services/workload-change.service.ts deleted file mode 100644 index f24b62a..0000000 --- a/frontend/src/main/web/src/app/services/workload-change.service.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { Injectable } from '@angular/core'; -import { BehaviorSubject } from 'rxjs'; -import { Workload } from '../model/workload'; - -@Injectable({ - providedIn: 'root' -}) -export class WorkloadChangeService { - - private newWorkloadSource = new BehaviorSubject( new Workload () ); - currentWorkload = this.newWorkloadSource.asObservable(); - - constructor() { } - - changeLaunchStatus(newWorkload: Workload) { - this.newWorkloadSource.next(newWorkload); - } -} diff --git a/frontend/src/main/web/src/app/use-case.service.ts b/frontend/src/main/web/src/app/use-case.service.ts index 1aea02c..7c7b9cd 100644 --- a/frontend/src/main/web/src/app/use-case.service.ts +++ b/frontend/src/main/web/src/app/use-case.service.ts @@ -5,7 +5,6 @@ import { Observable } from 'rxjs'; import {ApiResponse} from './model/api.response'; import {Workload} from './model/workload'; import { ApiResponseInterface } from './model/api.response.interface'; -import { WorkloadChangeService } from './services/workload-change.service'; import { BehaviorSubject } from 'rxjs'; @Injectable({ diff --git a/frontend/src/main/web/src/app/use-cases/use-cases.component.ts b/frontend/src/main/web/src/app/use-cases/use-cases.component.ts index 8eb610c..03cf7ca 100644 --- a/frontend/src/main/web/src/app/use-cases/use-cases.component.ts +++ b/frontend/src/main/web/src/app/use-cases/use-cases.component.ts @@ -199,7 +199,7 @@ dispUseCases(ctx:string) { useCaseCardComponent.setSelectionState(true,selectedIndex); console.log('Found card 0 ' + useCaseCardsAry[i].constructor.name); console.log('Found card: ' + i + ' : ' + useCaseCardsAry[i].getName() ); - break; + //2020-11-06 break; } } console.log("after ary"); @@ -229,7 +229,10 @@ dispUseCases(ctx:string) { this.useCaseService.currentWorkload.subscribe(workloadObj => { - /** The following works......however. + /** + * Refresh the checkbox/combobox selection with the newly applied WorkloadKey -- a text one. + * + * The following works......however. * when checkboxes are changed, then the following executes UNNECESSARILY. * Without this load() call, the new workload paints/renders/displays just fine. * @@ -241,8 +244,17 @@ dispUseCases(ctx:string) { * when the workloadKey(aka text) changes, set the dirty flag..... * and only execute this load() when the dirty flag is set. * .....and of course reset the dirty() flag when it is detected. + * + * ....or perhaps (and of course this is the right way) make a custom service specifically for: + * - clearTextWorkloadChange() + * - encryptedTextWorkloadChange() + * */ - this.load(); + if (workloadObj.origin==1) + //calling load() with origin==0 causes unnecessary and irritating page reload + this.load(); + //this.reSetUseCaseSelection(workloadObj); + } ); diff --git a/frontend/src/main/web/src/app/workload-key/workload-key.component.html b/frontend/src/main/web/src/app/workload-key/workload-key.component.html index 18a7b3c..3dce4de 100644 --- a/frontend/src/main/web/src/app/workload-key/workload-key.component.html +++ b/frontend/src/main/web/src/app/workload-key/workload-key.component.html @@ -10,12 +10,20 @@ Workload Key

+ diff --git a/frontend/src/main/web/src/app/workload-key/workload-key.component.ts b/frontend/src/main/web/src/app/workload-key/workload-key.component.ts index f42776c..b96cc99 100644 --- a/frontend/src/main/web/src/app/workload-key/workload-key.component.ts +++ b/frontend/src/main/web/src/app/workload-key/workload-key.component.ts @@ -41,6 +41,7 @@ export class WorkloadKeyComponent implements OnInit { private updateWorkload() { console.log("nnnnn about to parse selected workload:" + this.workloadKeyString); var workload:Workload = JSON.parse(this.workloadKeyString); + workload.origin = 1; this.useCaseService.updateWorkload( this.config.sutAppHostname, this.config.sutAppPort, diff --git a/frontend/src/main/web/src/app/workload-selection/workload-selection.html b/frontend/src/main/web/src/app/workload-selection/workload-selection.html index 1781bc0..556ce6c 100644 --- a/frontend/src/main/web/src/app/workload-selection/workload-selection.html +++ b/frontend/src/main/web/src/app/workload-selection/workload-selection.html @@ -80,7 +80,7 @@ - + diff --git a/workload/src/main/java/com/github/eostermueller/snail4j/workload/model/UseCases.java b/workload/src/main/java/com/github/eostermueller/snail4j/workload/model/UseCases.java index 604213c..38c6881 100644 --- a/workload/src/main/java/com/github/eostermueller/snail4j/workload/model/UseCases.java +++ b/workload/src/main/java/com/github/eostermueller/snail4j/workload/model/UseCases.java @@ -8,7 +8,15 @@ import com.github.eostermueller.snail4j.workload.Snail4jWorkloadException; public class UseCases { + int origin = 0; + + public int getOrigin() { + return origin; + } + public void setOrigin(int origin) { + this.origin = origin; + } public UseCases sort(Comparator c) { useCases.sort(c); return this; diff --git a/workload/src/main/java/com/github/eostermueller/snail4j/workload/model/json/DefaultSerializationUtil.java b/workload/src/main/java/com/github/eostermueller/snail4j/workload/model/json/DefaultSerializationUtil.java index 6eebf0c..f1e9c2e 100644 --- a/workload/src/main/java/com/github/eostermueller/snail4j/workload/model/json/DefaultSerializationUtil.java +++ b/workload/src/main/java/com/github/eostermueller/snail4j/workload/model/json/DefaultSerializationUtil.java @@ -4,6 +4,7 @@ import java.io.IOException; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.eostermueller.snail4j.workload.Snail4jWorkloadException; import com.github.eostermueller.snail4j.workload.model.UseCases; @@ -45,8 +46,10 @@ public UseCases unmmarshalUseCases(String json) throws Snail4jWorkloadException UseCases useCases = null; try { useCases = this.getMapper() + .configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true) .readerFor(UseCases.class) .readValue(json); + } catch (IOException e) { Snail4jWorkloadException he = new Snail4jWorkloadException(e,"Unable to unmarshal UseCases"); throw he; diff --git a/workload/src/test/java/com/github/eostermueller/snail4j/workload/model/json/JsonSerializationTest.java b/workload/src/test/java/com/github/eostermueller/snail4j/workload/model/json/JsonSerializationTest.java index 5f0a5f3..89dfe97 100644 --- a/workload/src/test/java/com/github/eostermueller/snail4j/workload/model/json/JsonSerializationTest.java +++ b/workload/src/test/java/com/github/eostermueller/snail4j/workload/model/json/JsonSerializationTest.java @@ -16,7 +16,7 @@ import com.github.eostermueller.snail4j.workload.model.WorkloadSpecRq; import com.github.eostermueller.snail4j.workload.model.json.SerializaionUtil; -class JsonSerializationTest { +public class JsonSerializationTest { private static final String USE_CASE_NAME = "Sorting"; private static final String BINARY_SORT_METHOD_NAME = "binarySort"; @@ -63,12 +63,35 @@ else if (myMethods[i].getName().equals("selectionSort")) // assertEquals( DECLARING_CLASS, m.getDeclaringClassName() ); // } - //@Test + @Test + public void canUnmarshallUseCase_real() throws Snail4jWorkloadException { + String js0n = "{\"useCases\":[{\"processingUnits\":[{\"description\":{\"en_US\":\"sleep ms 100\"},\"useCaseName\":\"03_threads_sleep\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.misc.SleepDelay\",\"methodName\":\"simulateSlowCode_sleepMilliseconds_100\"}},{\"description\":{\"en_US\":\"sleep ms 1\"},\"useCaseName\":\"03_threads_sleep\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.misc.SleepDelay\",\"methodName\":\"simulateSlowCode_sleepMilliseconds_1\"}},{\"description\":{\"en_US\":\"sync sleep ms 10\"},\"useCaseName\":\"03_threads_sleep\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.misc.SleepDelay\",\"methodName\":\"simulateSynchronizedSlowCode_sleepMilliseconds_10\"}},{\"description\":{\"en_US\":\"sleep ms 10\"},\"useCaseName\":\"03_threads_sleep\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.misc.SleepDelay\",\"methodName\":\"simulateSlowCode_sleepMilliseconds_10\"}},{\"description\":{\"en_US\":\"sleep ms 1000\"},\"useCaseName\":\"03_threads_sleep\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.misc.SleepDelay\",\"methodName\":\"simulateSlowCode_sleepMilliseconds_1000\"}},{\"description\":{\"en_US\":\"sync sleep ms 1000\"},\"useCaseName\":\"03_threads_sleep\",\"selected\":true,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.misc.SleepDelay\",\"methodName\":\"simulateSynchronizedSlowCode_sleepMilliseconds_1000\"}},{\"description\":{\"en_US\":\"sync sleep ms 1\"},\"useCaseName\":\"03_threads_sleep\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.misc.SleepDelay\",\"methodName\":\"simulateSynchronizedSlowCode_sleepMilliseconds_1\"}},{\"description\":{\"en_US\":\"sync sleep ms 100\"},\"useCaseName\":\"03_threads_sleep\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.misc.SleepDelay\",\"methodName\":\"simulateSynchronizedSlowCode_sleepMilliseconds_100\"}}],\"name\":\"03_threads_sleep\"}],\"origin\":2}"; + SerializaionUtil util = DefaultFactory.getFactory().createSerializationUtil(); + UseCases rq = util.unmmarshalUseCases(js0n); + assertEquals(1,rq.getUseCases().size() ); + assertEquals(8,rq.getUseCases().get(0).getProcessingUnits().size() ); + assertEquals( 2,rq.getOrigin()); + } + + @Test void canUnmarallUseCases() throws Snail4jWorkloadException { - String js0n = "{\"useCases\":[{\"processingUnits\":[{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - table-based Random - 10 items, 10 iterations\"}]},\"useCaseName\":\"busyOptimizedUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomTableInt_10_10_optimizedUuid\"},\"selected\":true},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - reuse Random - 10 items, 10 iterations\"}]},\"useCaseName\":\"busyOptimizedUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomNextInt_10_10_optimizedUuid\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - table-based Random - 1000 items, 1000 iterations\"}]},\"useCaseName\":\"busyOptimizedUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomTableInt_1000_1000_optimizedUuid\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - threadLocal Random - 1000 items, 1000 iterations\"}]},\"useCaseName\":\"busyOptimizedUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomThreadLocalInt_1000_1000_optimizedUuid\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - reuse Random - 1000 items, 1000 iterations\"}]},\"useCaseName\":\"busyOptimizedUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomNextInt_1000_1000_optimizedUuid\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - threadLocal Random - 10 items, 10 iterations\"}]},\"useCaseName\":\"busyOptimizedUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomThreadLocalInt_10_10_optimizedUuid\"},\"selected\":false}],\"name\":\"busyOptimizedUuid\"},{\"processingUnits\":[{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - threadLocal Random - 10 items, 10 iterations\"}]},\"useCaseName\":\"busySlowUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomThreadLocalInt_10_10\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - threadLocal Random - 1000 items, 1000 iterations\"}]},\"useCaseName\":\"busySlowUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomThreadLocalInt_1000_1000\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - table-based Random - 10 items, 10 iterations\"}]},\"useCaseName\":\"busySlowUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomTableInt_10_10\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - reuse Random - 10 items, 10 iterations\"}]},\"useCaseName\":\"busySlowUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomNextInt_10_10\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - reuse Random - 1000 items, 1000 iterations\"}]},\"useCaseName\":\"busySlowUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomNextInt_1000_1000\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"busy - table-based Random - 1000 items, 1000 iterations\"}]},\"useCaseName\":\"busySlowUuid\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.BusyProcessor\",\"name\":\"randomTableInt_1000_1000\"},\"selected\":false}],\"name\":\"busySlowUuid\"},{\"processingUnits\":[{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"every rq adds 10mb that stays in memory for no more than 60 seconds\"}]},\"useCaseName\":\"memStress\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.MemStress\",\"name\":\"memStress_10mb_lasts_60sec\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"every rq adds 100k that stays in memory for no more than 60 sec\"}]},\"useCaseName\":\"memStress\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.MemStress\",\"name\":\"memStress_100k_lasts_60sec\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"every rq adds 10k that stays in memory for no more than 5 min\"}]},\"useCaseName\":\"memStress\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.MemStress\",\"name\":\"memStress_10k_lasts_5min\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"every rq adds 1mb that stays in memory for no more than 60 seconds\"}]},\"useCaseName\":\"memStress\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.MemStress\",\"name\":\"memStress_1mb_lasts_60sec\"},\"selected\":false}],\"name\":\"memStress\"},{\"processingUnits\":[{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"sleep ms 100\"}]},\"useCaseName\":\"sleep\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.SleepDelay\",\"name\":\"simulateSlowCode_sleepMilliseconds_100\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"sleep ms 1\"}]},\"useCaseName\":\"sleep\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.SleepDelay\",\"name\":\"simulateSlowCode_sleepMilliseconds_1\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"sync sleep ms 10\"}]},\"useCaseName\":\"sleep\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.SleepDelay\",\"name\":\"simulateSynchronizedSlowCode_sleepMilliseconds_10\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"sleep ms 10\"}]},\"useCaseName\":\"sleep\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.SleepDelay\",\"name\":\"simulateSlowCode_sleepMilliseconds_10\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"sleep ms 1000\"}]},\"useCaseName\":\"sleep\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.SleepDelay\",\"name\":\"simulateSlowCode_sleepMilliseconds_1000\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"sync sleep ms 1000\"}]},\"useCaseName\":\"sleep\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.SleepDelay\",\"name\":\"simulateSynchronizedSlowCode_sleepMilliseconds_1000\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"sync sleep ms 1\"}]},\"useCaseName\":\"sleep\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.SleepDelay\",\"name\":\"simulateSynchronizedSlowCode_sleepMilliseconds_1\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"sync sleep ms 100\"}]},\"useCaseName\":\"sleep\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.SleepDelay\",\"name\":\"simulateSynchronizedSlowCode_sleepMilliseconds_100\"},\"selected\":false}],\"name\":\"sleep\"},{\"processingUnits\":[{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"Reuse same Transformers from pool\"}]},\"useCaseName\":\"xsltTransform\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.xslt.XsltProcessor\",\"name\":\"pooledTransformerXslt\"},\"selected\":false},{\"descriptor\":{\"messages\":[{\"locale\":\"en_US\",\"message\":\"Reinstantiate Transformer every time\"}]},\"useCaseName\":\"xsltTransform\",\"method\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.tjp2.xslt.XsltProcessor\",\"name\":\"unPooledTransformerXslt\"},\"selected\":false}],\"name\":\"xsltTransform\"}]}"; + String js0n = "{\"origin\":2,\"useCases\":[{\"processingUnits\":[{\"description\":{\"en_US\":\"MyMessage\"},\"useCaseName\":\"Sorting\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.snail4j.workload.model.json.Sorting\",\"methodName\":\"binarySort\"}},{\"description\":{\"en_US\":\"MyMessage\"},\"useCaseName\":\"Sorting\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.snail4j.workload.model.json.Sorting\",\"methodName\":\"selectionSort\"}}],\"name\":\"Sorting\"}]}"; SerializaionUtil util = DefaultFactory.getFactory().createSerializationUtil(); UseCases rq = util.unmmarshalUseCases(js0n); - assertEquals(5,rq.getUseCases().size() ); + assertEquals(1,rq.getUseCases().size() ); + assertEquals(2,rq.getUseCases().get(0).getProcessingUnits().size() ); + assertEquals( 2,rq.getOrigin()); + + } + @Test + void canUnmarallUseCasesWithDifferentOrder() throws Snail4jWorkloadException { + String js0n = "{\"useCases\":[{\"processingUnits\":[{\"description\":{\"en_US\":\"MyMessage\"},\"useCaseName\":\"Sorting\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.snail4j.workload.model.json.Sorting\",\"methodName\":\"binarySort\"}},{\"description\":{\"en_US\":\"MyMessage\"},\"useCaseName\":\"Sorting\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.snail4j.workload.model.json.Sorting\",\"methodName\":\"selectionSort\"}}],\"name\":\"Sorting\"}],\"origin\":2}"; + SerializaionUtil util = DefaultFactory.getFactory().createSerializationUtil(); + UseCases rq = util.unmmarshalUseCases(js0n); + assertEquals(1,rq.getUseCases().size() ); + assertEquals(2,rq.getUseCases().get(0).getProcessingUnits().size() ); + assertEquals( 2,rq.getOrigin()); + } //@Test void canUnmarallUseCasesRoundTrip() throws Snail4jWorkloadException { @@ -82,7 +105,7 @@ void canUnmarallUseCasesRoundTrip() throws Snail4jWorkloadException { } @Test - void canDoRoundTripSerialization() throws Snail4jWorkloadException { + public void canDoRoundTripSerialization() throws Snail4jWorkloadException { UseCases useCases = new UseCases(); useCases.addProcessingUnit( this.createTestProcessingUnit_Binary() ); @@ -175,7 +198,7 @@ void canUnmarshallWorkloadRequestToJson() throws Snail4jWorkloadException { } @Test - void canMarshallWorkloadRequestToJson() throws Snail4jWorkloadException { + public void canMarshallWorkloadRequestToJson() throws Snail4jWorkloadException { WorkloadSpecRq rq = new WorkloadSpecRq(); @@ -191,7 +214,7 @@ void canMarshallWorkloadRequestToJson() throws Snail4jWorkloadException { @Test - void canSerializeUseCasesToJson() throws Snail4jWorkloadException { + public void canSerializeUseCasesToJson() throws Snail4jWorkloadException { UseCases useCases = new UseCases(); useCases.addProcessingUnit( this.createTestProcessingUnit_Binary() ); @@ -200,7 +223,7 @@ void canSerializeUseCasesToJson() throws Snail4jWorkloadException { SerializaionUtil util = DefaultFactory.getFactory().createSerializationUtil(); String actualJson = util.marshalUseCases(useCases); System.out.println(actualJson); - String expectedJs0n = "{\"useCases\":[{\"processingUnits\":[{\"description\":{\"en_US\":\"MyMessage\"},\"useCaseName\":\"Sorting\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.snail4j.workload.model.json.Sorting\",\"methodName\":\"binarySort\"}},{\"description\":{\"en_US\":\"MyMessage\"},\"useCaseName\":\"Sorting\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.snail4j.workload.model.json.Sorting\",\"methodName\":\"selectionSort\"}}],\"name\":\"Sorting\"}]}"; + String expectedJs0n = "{\"origin\":0,\"useCases\":[{\"processingUnits\":[{\"description\":{\"en_US\":\"MyMessage\"},\"useCaseName\":\"Sorting\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.snail4j.workload.model.json.Sorting\",\"methodName\":\"binarySort\"}},{\"description\":{\"en_US\":\"MyMessage\"},\"useCaseName\":\"Sorting\",\"selected\":false,\"methodWrapper\":{\"parameters\":[],\"declaringClassName\":\"com.github.eostermueller.snail4j.workload.model.json.Sorting\",\"methodName\":\"selectionSort\"}}],\"name\":\"Sorting\"}]}"; assertEquals(expectedJs0n, actualJson);