Add unit tests for 10 previously-0%-coverage classes (123 tests)#5237
Conversation
Covers classes that had no test coverage, following the existing core-unittests conventions (JUnit 5, UITestBase/@formtest, the built-in TestCodenameOneImplementation mock; no Mockito, no reflection into the class under test, no inner-state mutation): - com.codename1.nfc.NfcReadOptions (NfcReadOptionsTest) - com.codename1.ai.ConversationStore (ConversationStoreTest) - com.codename1.ai.StreamingChatRequest (StreamingChatRequestTest) - com.codename1.camera.Camera (CameraTest) - com.codename1.camera.CameraSession (CameraSessionTest) - com.codename1.components.ChatBubble (ChatBubbleTest) - com.codename1.components.ChatInput (ChatInputTest) - com.codename1.components.ChatView (ChatViewTest) - com.codename1.router.Navigation (NavigationTest) - com.codename1.social.FirebaseAuth$FirebaseUser (FirebaseUserTest) Supporting changes: - TestCodenameOneImplementation gains an additive, backward-compatible camera hook (setCameraImpl + createCameraImpl override, cleared in reset()) so Camera/CameraSession can be driven against a hand-written RecordingCameraImpl test double instead of Mockito. The override returns null by default, matching the base class, so no existing test is affected. - RecordingCameraImpl: hand-written CameraImpl test double. StreamingChatRequest (package-private, abstract) is exercised through a concrete test subclass driven over the real mock-network path, covering SSE line reassembly, the [DONE] sentinel, CRLF/leading-space handling, clean completion, and HTTP-error mapping. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Fix: StreamingChatRequestTest used NetworkManager.addToQueueAndWait,
whose off-EDT path blocks on `while (!request.complete)` and could
deadlock on the network worker thread under JDK 21 (the build-test (21)
job timed out at 1h). The test now drives StreamingChatRequest.readResponse
directly (the test shares the com.codename1.ai package) with the subclass
overriding getResponseCode() to select the HTTP status. This is
deterministic, faster, and independent of the network thread; it also
drops the failSilently workaround that was only needed to dodge the
framework's unhandled-error dialog on the enqueue path.
New coverage (73 tests) for previously-0% classes, same conventions
(JUnit 5, UITestBase where a platform is needed, hand-written test
doubles; no Mockito, no reflection into the class under test):
- com.codename1.orm.EntityManager (EntityManagerTest)
- com.codename1.ai.RetryPolicy (RetryPolicyTest)
- com.codename1.nfc.Tag (TagTest)
- com.codename1.ai.ImageGenerator$OpenAiImageGenerator (ImageGeneratorTest)
- com.codename1.security.AuthenticationOptions (AuthenticationOptionsTest)
- com.codename1.nfc.Nfc (NfcTest)
- com.codename1.nfc.ApduResponse (ApduResponseTest)
- com.codename1.payment.WalletPassEntry (WalletPassEntryTest)
- com.codename1.ai.GenerateImageRequest (GenerateImageRequestTest)
- com.codename1.io.rest.RequestBuilder$FetchAsMappedListActionListener
(FetchAsMappedListTest)
EntityManager is driven against a hand-written recording Database + Dao;
ImageGenerator's OpenAiImageGenerator and the RequestBuilder mapped-list
listener are exercised over the mock network layer.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update: fixed the JDK 21 CI hang + added 10 more classesCI fixThe The test now drives New coverage (73 tests) for the next batch of 0% classes
Same conventions as before (JUnit 5, All new + changed tests pass locally. |
New coverage for previously-0% classes, same conventions (JUnit 5,
UITestBase where a platform is needed, hand-written test doubles; no
Mockito, no reflection into the class under test):
- com.codename1.gpu.Primitives (PrimitivesTest)
- com.codename1.io.graphql.GraphQL$GraphQLConnection (GraphQLConnectionTest)
- com.codename1.gaming.physics.box2d.pooling.normal.CircleStack
(CircleStackTest)
- com.codename1.system.SimulatorHookExecutor (SimulatorHookExecutorTest)
- com.codename1.media.TtsOptions (TtsOptionsTest)
- com.codename1.io.bonjour.BonjourPublisher (BonjourPublisherTest)
- com.codename1.ai.SimulatorRedirect (SimulatorRedirectTest)
- com.codename1.nfc.MifareClassic (MifareClassicTest)
- com.codename1.gaming.physics.box2d.pooling.stacks.DynamicIntStack
(DynamicIntStackTest)
- com.codename1.security.SecureStorage (SecureStorageTest)
Notes:
- Primitives is built against a headless GraphicsDevice subclass (the
buffer-allocation methods are concrete on the base class).
- GraphQLConnection (private) is driven through GraphQL.execute over the
mock network; the GraphQLConnection itself swallows the framework error
dialog and reports HTTP errors through the callback.
- SimulatorRedirect's simulator branch needs a platform name of "se";
TestCodenameOneImplementation gains an additive, reset-aware
setPlatformName (default "test") for that, and the test restores the
cn1.ai.* system properties it sets.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update: 10 more 0%-coverage classes (53 tests)Added coverage for: Highlights:
Same conventions as the rest of the PR (no Mockito, no reflection into the class under test, hand-written doubles). All 53 pass locally. |
New coverage for previously-0% classes, same conventions (JUnit 5,
UITestBase where a platform is needed, hand-written test doubles; no
Mockito, no reflection into the class under test):
- com.codename1.media.RecognitionOptions (RecognitionOptionsTest)
- com.codename1.gpu.Texture (TextureTest)
- com.codename1.ai.Tool (ToolTest)
- com.codename1.printing.PrintResult (PrintResultTest)
- com.codename1.printing.Printer (PrinterTest)
- com.codename1.io.rest.RequestBuilder$FetchAsMappedActionListener
(FetchAsMappedActionListenerTest)
- com.codename1.social.MicrosoftConnect (MicrosoftConnectTest)
- com.codename1.camera.CameraFrame (CameraFrameTest)
- com.codename1.io.bonjour.BonjourService (BonjourServiceTest)
FetchAsMappedActionListener (private) is driven through
RequestBuilder.fetchAsMapped over the mock connection with a registered
Mapper; Printer's listener path is pumped on the EDT.
Note on com.codename1.ui.Display$EdtException (also 0%): deliberately
left untested. It is a private async-stack-trace wrapper whose only code
path re-throws on the EDT; exercising it destabilises the EDT / surefire
fork, which isn't worth covering a private internal detail.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update: 9 more 0%-coverage classes (40 tests)Added coverage for: Notes:
Deliberately skipped:
|
New coverage for previously-0% classes, same conventions (JUnit 5, UITestBase where a platform is needed, hand-written test doubles; no Mockito, no reflection into the class under test): - com.codename1.gpu.GpuCapabilities (GpuCapabilitiesTest) - com.codename1.io.usb.UsbDevice (UsbDeviceTest) - com.codename1.io.wifi.WifiPlatform (WifiPlatformTest) - com.codename1.io.wifi.WiFi (WiFiTest) - com.codename1.io.bonjour.BonjourBrowser (BonjourBrowserTest) - com.codename1.gaming.SoundEffect (SoundEffectTest) - com.codename1.background.ForegroundService (ForegroundServiceTest) Notes: - WiFi / BonjourBrowser run against the no-op fallback platforms the base implementation supplies; ForegroundService runs its task on the default background-thread runner and is awaited via a latch. - SoundEffect's play/unload delegate to the pool's native peer, which casts the sound handle to its own internal type; those require a peer-loaded sound, so the test covers the constructor + accessors (built against the real fallback SoundPool) rather than playback. Two requested classes were deliberately left untested, for the same reason Display$EdtException was earlier -- both are private inner members reachable only through fragile, environment-dependent paths that destabilise a headless unit test: - com.codename1.social.MicrosoftConnect$DiscoveredCallback: a private SuccessCallback reached only via the live OIDC discovery -> authorize -> system-browser chain, which opens browser UI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Update: 7 more 0%-coverage classes (25 tests)Added coverage for: Notes:
Deliberately skipped:
|
Summary
Adds unit-test coverage for ten classes that previously had 0% coverage, raising 123 new green tests. All follow the existing
maven/core-unittestsconventions — JUnit 5,UITestBase/@FormTestfor UI components, the built-inTestCodenameOneImplementationmock — and deliberately avoid Mockito, reflection into the class under test, and inner-state mutation.com.codename1.nfc.NfcReadOptionsNfcReadOptionsTestcom.codename1.ai.ConversationStoreConversationStoreTestcom.codename1.ai.StreamingChatRequestStreamingChatRequestTestcom.codename1.camera.CameraCameraTestcom.codename1.camera.CameraSessionCameraSessionTestcom.codename1.components.ChatBubbleChatBubbleTestcom.codename1.components.ChatInputChatInputTestcom.codename1.components.ChatViewChatViewTestcom.codename1.router.NavigationNavigationTestcom.codename1.social.FirebaseAuth$FirebaseUserFirebaseUserTestHow the harder cases were reached without Mockito / reflection
TestCodenameOneImplementationgains a small, additive, backward-compatible camera hook (setCameraImpl+ acreateCameraImploverride cleared inreset()). Tests install a hand-writtenRecordingCameraImpldouble. The override returnsnullby default, exactly matching the base class, so no existing test changes behaviour.[DONE]sentinel, CRLF/leading-space handling, clean completion, and HTTP-error mapping.popToAPI;NavigationEntry's package-private constructor is reachable from the sharedcom.codename1.routerpackage.com.codename1.socialpackage; covers both the refresh (snake_case) and sign-in (camelCase) field mappings, expiry-parsing edge cases, and the JWT-claim email fallback.Test results
The only production-tree change is the additive camera hook in the test mock; everything else is new test code.
🤖 Generated with Claude Code