Skip to content

Introduce Spring codegen instances and collect types of mocked class variables #1791

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

Merged
merged 8 commits into from
Feb 14, 2023

Conversation

EgorkaKulikov
Copy link
Collaborator

@EgorkaKulikov EgorkaKulikov commented Feb 14, 2023

Description

Spring unit tests require to inject Mockito mocks in different way than pure Java tests.
To do it, we require per-class variables for all instances whose methods will be mocked in tests.
To collect per-class variables, we traverse all UtModels in test sets to find mocked classes.

Some refactoring of Cg-instances introduced: we would like to minimize regressions in standard codegen process.

How to test

Should not be tested separately, just some preparation logic for future Spring codegen and rendering.
Logic is temporarly disabled in main: isSpringClass=false.

Self-check list

  • I've set the proper labels for my PR (at least, for category and component).
  • PR title and description are clear and intelligible.
  • I've added enough comments to my code, particularly in hard-to-understand areas.
  • The functionality I've repaired, changed or added is covered with automated tests.
  • Manual tests have been provided optionally.
  • The documentation for the functionality I've been working on is up-to-date.

@EgorkaKulikov EgorkaKulikov added ctg-enhancement New feature, improvement or change request comp-codegen Issue is related to code generator comp-spring Issue is related to Spring projects support labels Feb 14, 2023
@EgorkaKulikov EgorkaKulikov marked this pull request as ready for review February 14, 2023 09:33
@EgorkaKulikov EgorkaKulikov requested a review from Damtev February 14, 2023 09:33
@EgorkaKulikov EgorkaKulikov changed the title Collect mocked class variables in Spring tests Introduce Spring codegen instances and collect types of mocked class variables Feb 14, 2023
Copy link
Member

@Damtev Damtev left a comment

Choose a reason for hiding this comment

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

Minor issues

@EgorkaKulikov EgorkaKulikov enabled auto-merge (squash) February 14, 2023 16:34
@EgorkaKulikov EgorkaKulikov merged commit c4c26f3 into main Feb 14, 2023
@EgorkaKulikov EgorkaKulikov deleted the egor/mocks_traverser branch February 14, 2023 16:51
@rudolf101 rudolf101 mentioned this pull request Feb 17, 2023
6 tasks
@alisevych alisevych added this to the 2023.03 Release milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-codegen Issue is related to code generator comp-spring Issue is related to Spring projects support ctg-enhancement New feature, improvement or change request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants