Skip to content

Add unit tests for classloader-test-library module#1165

Draft
Copilot wants to merge 3 commits intoypiel/QTDI-1914_sample_connector_dyndepsfrom
copilot/add-unit-tests-for-dynamic-dependencies
Draft

Add unit tests for classloader-test-library module#1165
Copilot wants to merge 3 commits intoypiel/QTDI-1914_sample_connector_dyndepsfrom
copilot/add-unit-tests-for-dynamic-dependencies

Conversation

Copy link

Copilot AI commented Feb 5, 2026

The classloader-test-library module in sample-parent/sample-features/dynamic-dependencies lacked test coverage. This module provides SPI consumer abstractions for validating classloader behavior across dependency scopes (standard, dynamic, external).

Changes

Test Coverage (13 tests)

  • DependencySPIConsumerTest - validates successful SPI loading via ServiceLoader with mock implementation
  • DynamicDependencySPIConsumerTest - validates error handling when SPI unavailable
  • ExternalDependencySPIConsumerTest - validates external dependency SPI behavior

Test Infrastructure

  • MockStringProviderSPIAsDependency - test implementation of StringProviderSPIAsDependency interface
  • META-INF/services descriptor for ServiceLoader discovery

Tests verify:

  • SPI loading via ServiceLoader.load() with present/absent implementations
  • Optional<S> handling in AbstractSPIConsumer.getSPIImpl()
  • Generic transform() functionality with various return types
  • Error message generation for missing services

Example test pattern:

@Test
void testGetValue_withSPILoaded() {
    DependencySPIConsumer<String> consumer = new DependencySPIConsumer<>();
    String value = consumer.getValue();
    
    assertEquals("Mock value from dependency", value);
}

@Test
void testTransform_withIntegerReturn() {
    DependencySPIConsumer<Integer> consumer = new DependencySPIConsumer<>();
    Integer length = consumer.transform(String::length);
    
    assertTrue(length > 0);
}
Original prompt

Please create a new branch based on ypiel/QTDI-1914_sample_connector_dyndeps. Your goal is to add relevant unit test in sub-modules of sample-parent/sample-features/dynamic-dependencies. Maybe you will have to refactor a little exisintg code to be able to add unit test.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 5, 2026 14:35
Co-authored-by: ypiel-talend <29707101+ypiel-talend@users.noreply.github.com>
Co-authored-by: ypiel-talend <29707101+ypiel-talend@users.noreply.github.com>
Copilot AI changed the title [WIP] Add relevant unit tests in dynamic dependencies sub-modules Add unit tests for classloader-test-library module Feb 5, 2026
Copilot AI requested a review from ypiel-talend February 5, 2026 15:17
Copilot stopped work on behalf of ypiel-talend due to an error February 5, 2026 15:17
@sonar-eks
Copy link

sonar-eks bot commented Feb 5, 2026

Failed Quality Gate failed

  • 3 New Issues (is greater than 0)

Project ID: org.talend.sdk.component:component-runtime

View in SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants