-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Improve Test Coverage - JdlService #253
Conversation
Jdl jdl = mock(Jdl.class); | ||
jdlMetadata.setName("jdl-metadata-name"); | ||
given(jdlRepository.findOneByJdlMetadataId(jdlMetadata.getId())).willReturn(Optional.of(jdl)); | ||
given(githubService.getHost()).willReturn("https://www.github.com"); |
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.
I would use the property application.github.host
from application.yml
instead of hardcoding https://www.github.com
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.
Done
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.
@roexber : Not sure this is done, as I don't see the property application.github.host
being used. Also we need to add that property to the application.yml
file as it's not there;
# application: |
application:
github:
host: https://github.com
gitlab:
host: https://gitlab.com
in the application.yml
file and then you could refer to that using .willReturn(applicationProperties.getGithub().getHost())
.
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.
@SudharakaP due to
@EnableConfigurationProperties(value = ApplicationProperties.class)
@TestPropertySource("classpath:config/application.yml")
on the test class and
@Autowired
private ApplicationProperties applicationProperties;
the properties are loaded from
src/test/resources/config/application.yml
I'm not explicitly overriding since there are sensible defaults set on io.github.jhipster.online.config.ApplicationProperties Github and Gitlab child classes
public static class Github {
private String host = "https://github.com";
Testing if spring property loading works seemed out of scope, I'll override them anyway to make sure the default is substituted.
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.
Tried adding
application:
github:
host: github.test
gitlab:
host: gitlab.test
to the src/test/resources/config/application.yml without much luck... not sure how to go about it next
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.
Managed to figure this one out using the help of @patrickhancke
src/test/java/io/github/jhipster/online/service/JdlServiceTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/github/jhipster/online/service/JdlServiceTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/github/jhipster/online/service/JdlServiceTest.java
Outdated
Show resolved
Hide resolved
741670f
to
ec0ab45
Compare
ec0ab45
to
232ed21
Compare
@SudharakaP should be better now as its picking up the src/test/resrouces application.yml configuration in the test assertions |
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.
@SudharakaP should be better now as its picking up the src/test/resrouces application.yml configuration in the test assertions
Thanks a lot for the work. I've added some minor comments to the review, and after that I think we are good to go. 👍🏽
src/test/java/io/github/jhipster/online/service/JdlServiceTest.java
Outdated
Show resolved
Hide resolved
src/test/java/io/github/jhipster/online/service/JdlServiceTest.java
Outdated
Show resolved
Hide resolved
232ed21
to
4dc2c62
Compare
@roexber : Thanks a lot for your contribution, greatly appreciate what you are doing here. 😄 |
Related to #213