-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Removed unnecessary code from getGuestOsType in CitrixResourceBase #1262
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
Conversation
|
@cristofolini could you please remove the @Local annotation from CitrixResourceBase ? |
0e97ca6 to
935113f
Compare
|
@rafaelweingartner Done. |
ACS CI BVT RunSumarry: Link to logs Folder (search by build_no): https://www.dropbox.com/sh/yj3wnzbceo9uef2/AAB6u-Iap-xztdm6jHX9SjPja?dl=0 Failed tests: Skipped tests: Passed test suits: |
|
@cristofolini, I can give an LGTM for this PR. |
|
@swill another one that seems to be ready to be merged. |
|
@rafaelweingartner yes, I think this is ready too. I am trying to get two LGTM for every PR, so can someone else from the dev list give me a review? |
|
I agree with you |
|
Do we need the tests in all child-test classes? otherwise LGTM |
|
@DaanHoogland that is a good question. The point here is that it is an abstract class being tested. So, instead of removing the abstract from that class, we tested the method in each of its implementations. |
|
@rafaelweingartner how about creating a test-child instead of testing in all child-tests ;) |
|
@DaanHoogland, I did not understand what you meant with test-child. We could do the test a little bit different if we had a newer version of Mockito using the spy method. But, with the one we are using, we did not find much ways to write tests for that class, given that it is an abstract class. Could you elaborate a little bit more your idea? |
|
Well @rafaelweingartner you can make a test class for each of the child classes of the abstract class, as done now or you can make a CitrixResourceTest-class child of the abstract class and test with that one. You could even make it an anonymous class in the test. I am not sure but maybe you can even mock/spy an abstract class and have the testable method be called without any child. Does that explain? |
|
Sure it does. And yes we can create a spy from an abstract class. The problem is that with the current version of Mockito the spy method only works for Objects and not for classes; we would need to create an anonymous class. Using the mock method would no work. I also thought about using an anonymous class, but that seemed not elegant to me. However, if you find it interesting, we could do that way (with an anonymous class). Then, we would not even need to work with mocks. |
|
Well, I am not interested in elegant at this stage, just in reducing the code base if it make sense. The simplest solution is an named test resource class as child of CitrixResourceBase and test on that one. |
|
Got your point. |
|
@DaanHoogland Done. |
|
@rafaelweingartner a lot less code (not in the diff but in the result) 👍 |
|
I agree with you. Probably I was trying to be too perfectionist; I did not like that. Anyways, I hope we bump Mockito version soon, so I can fix that. |
|
I am going to add this to my CI queue. Please reconfirm the LGTM's votes based on the updated code. Thanks... |
|
LGTM |
|
Can I get the commits squashed and repushed with |
|
Will, I don't like manic squashing, why not preserve history. |
|
Some history is fine, but we don't need the whole history for every change in master. I don't think this adds much by adding it to the master commit tree: c7b9739 Also, I need jenkins to run again, so I was killing two birds with one stone... :) |
|
@DaanHoogland, I agree with Will. The last commit should be squashed. I will do that. |
c7b9739 to
78eb6c1
Compare
|
@DaanHoogland, @swill commits squashed. |
8956676 to
2130be8
Compare
2130be8 to
c0e7161
Compare
c0e7161 to
8355b58
Compare
|
I need one more LGTM code review of this one, otherwise it is looking to be in good order... |
|
In this situation, I do not know if mine would count, giving that I also have helped with some code changes. |
|
@rafaelweingartner I understand you feel like you have a conflict of interests, but at the same time, you are also very familiar with the code so are in a good position to review it. If you trust yourself to be critical of the code in your review, I trust your review. :P |
|
@swill thanks for the support. I sure can give an LGTM to it. |
|
Ok perfect, thanks @rafaelweingartner. I will get this merged... |
Removed unnecessary code from getGuestOsType in CitrixResourceBaseConsidering that all mapping of Guest OS Names to their respective hypervisor compatible types is made thorugh accessing a database, we've decided to remove a bit of code in the XcpOssResource class which was doing that same thing for 2 different OS's (both of which ARE in the database). That has led us to a bunch of unused parameters in the getGuestOsType method from its superclass, which we've also decided to remove. Test cases were added for four different possibilities for the platformEmulator String: one for a null String, one for a blank String, one for an empy String and one for a random case with a valid String. * pr/1262: Remove test cases duplicated code. Removed unnecessary code from getGuestOsType in CitrixResourceBase Signed-off-by: Will Stevens <williamstevens@gmail.com>
Considering that all mapping of Guest OS Names to their respective hypervisor compatible types is made thorugh accessing a database, we've decided to remove a bit of code in the XcpOssResource class which was doing that same thing for 2 different OS's (both of which ARE in the database). That has led us to a bunch of unused parameters in the getGuestOsType method from its superclass, which we've also decided to remove. Test cases were added for four different possibilities for the platformEmulator String: one for a null String, one for a blank String, one for an empy String and one for a random case with a valid String.