-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Test for DbInfoController and SchemaController [resolves #715] #728
Open
Shrman007658
wants to merge
3
commits into
9tigerio:master
Choose a base branch
from
Shrman007658:addTestsDbMeta
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+355
−0
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This class is responsible for returning the metadata about the databases connected to the service. Added one test for the getObjects method which returns a list of DbInfoObject.
This class is responsible for filtering out schemas on 3 parameters, schema, name and type. Added tests to test filtering on all these attributes. Also added tests for GenericDataAccessException when the filter is not formatted properly and the given DBID does not exist
Shrman007658
changed the title
Adding Test for DbInfoController class
Adding Test for DbInfoController class [#715]
Oct 7, 2024
Shrman007658
changed the title
Adding Test for DbInfoController class [#715]
Adding Test for DbInfoController class [resolves #715]
Oct 7, 2024
kdhrubo
requested changes
Oct 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be integration test.
thadguidry
requested changes
Oct 8, 2024
api-rest/src/test/java/com/homihq/db2rest/jdbc/rest/meta/schema/SchemaControllerTest.java
Show resolved
Hide resolved
He has written unit test. As Lenur wrote in the issue we rely on
integration test.
…On Mon, Oct 7, 2024, 8:40 PM Thad Guidry ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In
api-rest/src/test/java/com/homihq/db2rest/jdbc/rest/meta/schema/SchemaControllerTest.java
<#728 (comment)>:
> + @test
+ void testGetObjectsValidFilter_type() {
+ when(jdbcManager.getDbMetaByDbId("key")).thenReturn(metadataMap.get("key"));
+ List<TableObject> expectedTableObject = metadataMap.get("key").dbTables().stream().map(t-> new TableObject(t.schema(),t.name(),t.type())).toList();
+ List<TableObject> actualTableObject = schemaController.getObjects("key","type==type");
+ assertEquals(expectedTableObject,actualTableObject);
+
+ actualTableObject = schemaController.getObjects("key","type==notPresentInList");
+ assertEquals(0,actualTableObject.size());
+ }
+ @test
+ void testGetObjectsValidFilter_invalidFieldFilter() {
+ when(jdbcManager.getDbMetaByDbId("key")).thenReturn(metadataMap.get("key"));
+ List<TableObject> actualTableObject;
+ actualTableObject = schemaController.getObjects("key","invalidFilterField==notPresentInList");
+ assertEquals(0,actualTableObject.size());
Hmm, that looks awkward. We filter against a field, it's not found, and so
we return an empty list.
@kdhrubo <https://github.com/kdhrubo> Should we improve the code to
return a simple message such as "No matches found."? Or is empty List
enough? If empty List is assumed to be the same as "No matches found.",
then we should change this test result to not check a size, but ensure what
actually is being returned with assertEquals(actualTableObject.isEmpty())
Some say "always return some object or message, never null". Others say
its fine for APIs to return nothing. But even nothing is always represented
by some object or message. In this case, an empty List object. So we should
improve this.
—
Reply to this email directly, view it on GitHub
<#728 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAISPRHDQYXHBWFMNDY3C6TZ2MZZ3AVCNFSM6AAAAABPQAPCKGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGNJTGIYDKNZYGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Okay, I will try to add Integration tests as well. But as a good to have are we keeping the Unit Tests at all or should I remove both of the classes? |
Shrman007658
changed the title
Adding Test for DbInfoController class [resolves #715]
Adding Test for DbInfoController and SchemaController [resolves #715]
Oct 8, 2024
kindly requesting re review |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This class is responsible for returning the metadata about the databases connected to the service. Added one test for the getObjects method which returns a list of DbInfoObject.
resolves #715