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

Update RpmTest to Junit5 #36

Merged
merged 4 commits into from
Mar 13, 2020
Merged

Update RpmTest to Junit5 #36

merged 4 commits into from
Mar 13, 2020

Conversation

HDouss
Copy link
Contributor

@HDouss HDouss commented Mar 12, 2020

Resolving issue #32

  • Converting to JUnit 5
  • Extracting method for common behavior
  • Rid of PMD warning suppression
  • Update puzzle for remaining tasks

@paulodamaso
Copy link
Contributor

@g4s8 PLease assign me

@HDouss
Copy link
Contributor Author

HDouss commented Mar 12, 2020

@0crat status

Copy link
Contributor

@paulodamaso paulodamaso left a comment

Choose a reason for hiding this comment

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

@HDouss There are some comments, please take a look

home.toFile().mkdirs();
final Storage storage = new FileStorage(home);
final Path bin = this.folder.newFile("x.rpm").toPath();
public void updateAarchRpm(@TempDir final Path folder, @TempDir final Path store)
Copy link
Contributor

Choose a reason for hiding this comment

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

@HDouss Typo in Aarch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulodamaso I don't think so. Please see #32 and #30

StandardCopyOption.REPLACE_EXISTING
);
storage.save(new Key.From(key), new RxFile(bin).flow()).get();
final Storage storage = RpmTest.save(folder, store, key);
Copy link
Contributor

Choose a reason for hiding this comment

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

@HDouss Couldn't you inline all in line 110?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulodamaso Didn't get it. Inline what?

Copy link
Contributor

Choose a reason for hiding this comment

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

@HDouss Something like this:

        MatcherAssert.assertThat(
            new Threads<>(
                threads,
                new Repeated<Scalar<Boolean>>(
                    threads,
                    () -> {
                        new Rpm(RpmTest.save(folder, store, key)).update(key).blockingAwait();
                        return true;
                    }
                )
            ),
            Matchers.iterableWithSize(threads)
        ); 

Also, use IsIterableWithSize instead Matchers.iterableWithSize

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulodamaso Inlined rpm, but I can't inline storage as it is used afterwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulodamaso could not inline rpm either as it will create a new rpm for each thread. That will make the test fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

@HDouss Good point. Let it be, then

String.format("repodata/%s", file)
).toFile().exists(),
Matchers.equalTo(true)
);
}
}

private static Storage save(final Path folder, final Path store, final String key)
Copy link
Contributor

Choose a reason for hiding this comment

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

@HDouss I 'dont like the idea of sharing this piece of code among all our test cases; a bug in here could get us false results from all our tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulodamaso This part is asked by the puzzle. Besides, isn't that the benefit of behavior encapsulation/method extraction? If a bug is there, either a fix will fix all the tests, or the tests should be splitted because they don't require the same behavior anymore. Given that they share the same behavior for now, it is good to have that I think.

Copy link
Contributor

Choose a reason for hiding this comment

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

@HDouss I prefer to have all code for creating the data needed in my test cases inside the test, but it is a particular preference. I consider that sharing a untested code (usually these helper function in tests aren't tested, since they are not production code) is more harmful than repeating very similar code for the creation of each test data. By the way, having to create lots of complex objects so we can run the tests may point to the fact that we have architectural problems in code, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@paulidamaso I understand even I don't fully agree. What do we do with the fact that this is what asked by the puzzle/issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

@HDouss Don't change anything; I can fill a bug if I feel the need of refactoring it

@0crat
Copy link

0crat commented Mar 12, 2020

This pull request #36 is assigned to @paulodamaso/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @g4s8/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewer; there will be a monetary reward for this job

@0crat
Copy link

0crat commented Mar 12, 2020

@0crat status (here)

@HDouss This is what I know about this job in CT2E6TK9B, as in §32:

Copy link
Contributor

@paulodamaso paulodamaso left a comment

Choose a reason for hiding this comment

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

@HDouss Please take a look at the answers. Also, please add some meaningful test to the PR title.

String.format("repodata/%s", file)
).toFile().exists(),
Matchers.equalTo(true)
);
}
}

private static Storage save(final Path folder, final Path store, final String key)
Copy link
Contributor

Choose a reason for hiding this comment

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

@HDouss I prefer to have all code for creating the data needed in my test cases inside the test, but it is a particular preference. I consider that sharing a untested code (usually these helper function in tests aren't tested, since they are not production code) is more harmful than repeating very similar code for the creation of each test data. By the way, having to create lots of complex objects so we can run the tests may point to the fact that we have architectural problems in code, too.

StandardCopyOption.REPLACE_EXISTING
);
storage.save(new Key.From(key), new RxFile(bin).flow()).get();
final Storage storage = RpmTest.save(folder, store, key);
Copy link
Contributor

Choose a reason for hiding this comment

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

@HDouss Something like this:

        MatcherAssert.assertThat(
            new Threads<>(
                threads,
                new Repeated<Scalar<Boolean>>(
                    threads,
                    () -> {
                        new Rpm(RpmTest.save(folder, store, key)).update(key).blockingAwait();
                        return true;
                    }
                )
            ),
            Matchers.iterableWithSize(threads)
        ); 

Also, use IsIterableWithSize instead Matchers.iterableWithSize

@0crat
Copy link

0crat commented Mar 12, 2020

Job #36 is already in scope

@HDouss
Copy link
Contributor Author

HDouss commented Mar 12, 2020

@paulodamaso Fixed. About the last point: the method is just copying a file a store it in the storage. The key/file resource being "dynamic" as it is passed as arg. Besides, this is what have been asked by the issue.

@paulodamaso
Copy link
Contributor

@HDouss Just need to merge changes form master now

@HDouss
Copy link
Contributor Author

HDouss commented Mar 12, 2020

@paulodamaso Thanks. Done!

@paulodamaso
Copy link
Contributor

@g4s8 Good to merge

@g4s8 g4s8 changed the title #32 Update RpmTest to Junit5 Mar 13, 2020
@g4s8 g4s8 merged commit 2e738e2 into artipie:master Mar 13, 2020
@g4s8
Copy link
Member

g4s8 commented Mar 13, 2020

@HDouss thanks, merged. Please try to use more sensible PR titles next time.

@HDouss
Copy link
Contributor Author

HDouss commented Mar 13, 2020

@HDouss thanks, merged. Please try to use more sensible PR titles next time.

@g4s8 Sure. Thanks!

@0crat 0crat removed the scope label Mar 13, 2020
@0crat
Copy link

0crat commented Mar 13, 2020

Job was finished in 18 hours, bonus for fast delivery is possible (see §36)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants