Skip to content
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

#4414 implement Set #2

Open
wants to merge 2 commits into
base: development
Choose a base branch
from
Open

#4414 implement Set #2

wants to merge 2 commits into from

Conversation

rogin
Copy link
Owner

@rogin rogin commented Aug 8, 2023

I have TODOs in the tests which welcome feedback involving what should happen when nulls are passed to various functions.


private Map<String, Integer> destinationIdMap;
private Map<String, Integer> destinationIdMap = Collections.emptyMap();
private Set<Integer> metaDataIds;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this also default to Collections.emptySet() ?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, as we use its add() which emptySet() doesn't implement

@@ -43,6 +47,7 @@ public DestinationSet(ImmutableConnectorMessage connectorMessage) {
this.metaDataIds = (Set<Integer>) connectorMessage.getSourceMap().get(Constants.DESTINATION_SET_KEY);
}
} catch (Exception e) {
metaDataIds = new HashSet<>();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the catch block even necessary here?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the rare case of a ClassCastException when pulling out the SourceMap. Until they fix that, it's worth leaving.

assertEquals(4, ds.size());
assertTrue(ds.addAll(Arrays.asList(5, 6)));
assertEquals(6, ds.size());
//TODO is this what we want?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. The behavior of DestiationSet is such that if any operation fails, it returns false

assertFalse(ds.containsAll(Arrays.asList("Invalid")));
assertFalse(ds.containsAll(Collections.singleton(null)));
//TODO is this what we want?
assertFalse(ds.containsAll(null));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is what you want

@rogin rogin marked this pull request as ready for review September 6, 2023 17:06
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