Skip to content

Conversation

serhii-lekariev
Copy link
Contributor

@serhii-lekariev serhii-lekariev commented Dec 12, 2018

This PR addresses #165.

Now assertMatchesMask doesn't skip repeated fields, and instead checks whether at least 1 value is present, and calls a respective assert.

However, repeated fields are only allowed as a last field in the respective mask, so while mask

mask {
    paths: friends
}

can match for a user with friends

message Animal {
    string kind = 1;
}
     
message User {
    string name = 1;
    repeated User friends = 2;
    repeated Animal animals = 3;
}

a mask

mask {
    paths: animals.kind
}

cannot match for any user, because a repeated field is not used as a last one.

@serhii-lekariev serhii-lekariev self-assigned this Dec 12, 2018
@codecov
Copy link

codecov bot commented Dec 12, 2018

Codecov Report

Merging #250 into master will increase coverage by 0.04%.
The diff coverage is 90.9%.

@@             Coverage Diff              @@
##             master     #250      +/-   ##
============================================
+ Coverage     66.38%   66.43%   +0.04%     
- Complexity      583      584       +1     
============================================
  Files           310      310              
  Lines          8158     8167       +9     
  Branches        561      562       +1     
============================================
+ Hits           5416     5426      +10     
+ Misses         2625     2624       -1     
  Partials        117      117

@serhii-lekariev
Copy link
Contributor Author

@armiol, PTAL.

Copy link
Collaborator

@armiol armiol left a comment

Choose a reason for hiding this comment

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

@serhii-lekariev please see my comments.

assertThat(fieldNames).containsAllIn(paths);

// Assert that values match the field mask.
for (FieldDescriptor field : fields) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This piece of code looks unformatted.

for (FieldDescriptor field : fields) {
if (field.isRepeated()) {
continue;
boolean pathsHasSuchField = paths.contains(field.getName());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's discuss what this test does.

@serhii-lekariev
Copy link
Contributor Author

@armiol, PTAL.

@serhii-lekariev
Copy link
Contributor Author

@dmdashenkov, PTAL.

Copy link
Contributor

@dmdashenkov dmdashenkov left a comment

Choose a reason for hiding this comment

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

@serhii-lekariev, please see my comments.

@serhii-lekariev
Copy link
Contributor Author

@dmdashenkov, PTAL.

Copy link
Contributor

@dmdashenkov dmdashenkov left a comment

Choose a reason for hiding this comment

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

@serhii-lekariev, please fix a few minor comments and LGTM.

@serhii-lekariev serhii-lekariev merged commit 79335ea into master Dec 13, 2018
@serhii-lekariev serhii-lekariev deleted the fieldmask-repeated-fields branch December 13, 2018 13:25
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.

3 participants