Title: Issues with mocking command chain types in tests
Description
When trying to mock the Helm command chain in unit tests, we're encountering issues with type definitions that make it difficult to properly mock the fluent API. This affects the ability to write comprehensive unit tests for code that uses the helm-java library.
Current Setup
- helm-java version: 0.0.15
- Testing framework: JUnit 5 with Mockito
- Java version: 17
Problem
The current type system makes it challenging to mock the command chain properly. For example, when trying to mock the repo command chain:
@Mock private RepoCommand repoCommand;
when(helm.repo()).thenReturn(repoCommand);
when(repoCommand.add()).thenReturn(repoCommand);
when(repoCommand.withName(anyString())).thenReturn(repoCommand);
when(repoCommand.withUrl(any(URI.class))).thenReturn(repoCommand);
We get compilation errors like:
- The method
withName(String) is undefined for the type RepoCommand
- The method
withUrl(any(URI.class)) is undefined for the type RepoCommand
- The method
call() is undefined for the type RepoCommand
Similar issues occur with InstallCommand and UninstallCommand.
Expected Behavior
The type system should expose the fluent API methods properly to allow for straightforward mocking in tests. This would enable:
- Proper type checking during compilation
- Better IDE support for method chaining
- More maintainable test code
Current Workaround
We're currently working around this by using minimal mocking:
RepoCommand repoCommand = mock(RepoCommand.class);
when(helm.repo()).thenReturn(repoCommand);
However, this doesn't allow us to properly verify the command chain configuration.
Questions
- What is the recommended way to mock the command chain in tests?
- Are there specific types we should be using for the mock objects?
- Is there documentation available for testing with the library?
Additional Context
We're using this library in a service that manages Helm deployments through Java code. Having proper testing support is crucial for maintaining reliability.
Let me know if you need any additional information or clarification.
Title: Issues with mocking command chain types in tests
Description
When trying to mock the Helm command chain in unit tests, we're encountering issues with type definitions that make it difficult to properly mock the fluent API. This affects the ability to write comprehensive unit tests for code that uses the helm-java library.
Current Setup
Problem
The current type system makes it challenging to mock the command chain properly. For example, when trying to mock the repo command chain:
We get compilation errors like:
withName(String)is undefined for the typeRepoCommandwithUrl(any(URI.class))is undefined for the typeRepoCommandcall()is undefined for the typeRepoCommandSimilar issues occur with
InstallCommandandUninstallCommand.Expected Behavior
The type system should expose the fluent API methods properly to allow for straightforward mocking in tests. This would enable:
Current Workaround
We're currently working around this by using minimal mocking:
However, this doesn't allow us to properly verify the command chain configuration.
Questions
Additional Context
We're using this library in a service that manages Helm deployments through Java code. Having proper testing support is crucial for maintaining reliability.
Let me know if you need any additional information or clarification.