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

Improve Test Coverage - JdlService #253

Merged
merged 1 commit into from
Oct 30, 2020

Conversation

roexber
Copy link
Contributor

@roexber roexber commented Oct 26, 2020

Related to #213

@SudharakaP SudharakaP changed the title Improve-test-coverage - JdlService Improve Test Coverage - JdlService Oct 26, 2020
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");
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

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;

. So ultimately we would have,

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()).

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

@roexber
Copy link
Contributor Author

roexber commented Oct 28, 2020

@SudharakaP should be better now as its picking up the src/test/resrouces application.yml configuration in the test assertions

Copy link
Member

@SudharakaP SudharakaP left a 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. 👍🏽

@SudharakaP SudharakaP merged commit c802ece into jhipster:master Oct 30, 2020
@SudharakaP
Copy link
Member

@roexber : Thanks a lot for your contribution, greatly appreciate what you are doing here. 😄

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