@@ -146,6 +146,63 @@ public void generateModeVerdict_DeduplicatesAndOrdersMatches() {
146146 }
147147 }
148148
149+ @ Test
150+ public void generateModeVerdict_DeduplicatesNumbersInMatches () {
151+ OutputStructure .logsOutputDir = Path .of ("target" ).toString ();
152+ OutputStructure .startInnerLoopDateString = "YYYY-MM-DD_hh-mm-ss" ;
153+ OutputStructure .executedSUTname = "test-sut" ;
154+
155+ Settings settings = buildSettings (RuntimeControlsProtocol .Modes .Generate , "(?i)(.*Exception.*)" );
156+ AndroidLogcatOracle androidLogcatOracle = new AndroidLogcatOracle (settings );
157+ State state = Mockito .mock (State .class );
158+
159+ String line1 = "02-09 08:59:33.844 17550 17575 E ViewRootImpl: Exception @1:207875, unable to find 3421 viewState" ;
160+ String line2 = "02-09 08:59:33.845 17550 17575 E ViewRootImpl: Exception @1:204868, unable to find 9008 viewState" ;
161+
162+ try (MockedStatic <AndroidAppiumFramework > mocked = Mockito .mockStatic (AndroidAppiumFramework .class )) {
163+ mocked .when (AndroidAppiumFramework ::getAppPackageFromCapabilitiesOrCurrent ).thenReturn ("org.testar.app" );
164+ mocked .when (() -> AndroidAppiumFramework .dumpLogcatThreadtimeForPackage ("org.testar.app" ))
165+ .thenReturn (line1 + "\n " + line2 );
166+
167+ androidLogcatOracle .initialize ();
168+ Verdict verdict = androidLogcatOracle .getVerdict (state );
169+
170+ Assert .assertEquals (Verdict .Severity .SUSPICIOUS_LOG .getValue (), verdict .severity (), 0.0 );
171+ String expected = "Suspicious Android logcat line(s) detected "
172+ + "ViewRootImpl: Exception @<num>:<num>, unable to find <num> viewState" ;
173+ Assert .assertEquals (expected , verdict .info ());
174+ }
175+ }
176+
177+ @ Test
178+ public void generateModeVerdict_KeepsHttpStatusCodes () {
179+ OutputStructure .logsOutputDir = Path .of ("target" ).toString ();
180+ OutputStructure .startInnerLoopDateString = "YYYY-MM-DD_hh-mm-ss" ;
181+ OutputStructure .executedSUTname = "test-sut" ;
182+
183+ Settings settings = buildSettings (RuntimeControlsProtocol .Modes .Generate , "(?i)(.*Exception.*)" );
184+ AndroidLogcatOracle androidLogcatOracle = new AndroidLogcatOracle (settings );
185+ State state = Mockito .mock (State .class );
186+
187+ String line1 = "02-09 08:59:33.844 17550 17575 E ViewRootImpl: Exception, http status 404" ;
188+ String line2 = "02-09 08:59:33.845 17550 17575 E ViewRootImpl: Exception, http status 503" ;
189+
190+ try (MockedStatic <AndroidAppiumFramework > mocked = Mockito .mockStatic (AndroidAppiumFramework .class )) {
191+ mocked .when (AndroidAppiumFramework ::getAppPackageFromCapabilitiesOrCurrent ).thenReturn ("org.testar.app" );
192+ mocked .when (() -> AndroidAppiumFramework .dumpLogcatThreadtimeForPackage ("org.testar.app" ))
193+ .thenReturn (line1 + "\n " + line2 );
194+
195+ androidLogcatOracle .initialize ();
196+ Verdict verdict = androidLogcatOracle .getVerdict (state );
197+
198+ Assert .assertEquals (Verdict .Severity .SUSPICIOUS_LOG .getValue (), verdict .severity (), 0.0 );
199+ String expected = "Suspicious Android logcat line(s) detected "
200+ + "ViewRootImpl: Exception, http status 404"
201+ + " | ViewRootImpl: Exception, http status 503" ;
202+ Assert .assertEquals (expected , verdict .info ());
203+ }
204+ }
205+
149206 private Settings buildSettings (RuntimeControlsProtocol .Modes mode , String regex ) {
150207 List <Pair <?, ?>> tags = new ArrayList <>();
151208 tags .add (Pair .from (ConfigTags .Mode , mode ));
0 commit comments