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

Sonar: Remove this unused method parameter em #26132

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class PublicUserResourceIT {
<%_ } _%>
@BeforeEach
public void initTest() {
user = UserResourceIT.initTestUser(userRepository<% if (databaseTypeSql) { %>, em<% } %>);
user = UserResourceIT.initTestUser(userRepository);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ import org.springframework.transaction.annotation.Transactional;
import reactor.core.publisher.Mono;
<%_ } _%>

<%_ if (databaseTypeSql && !reactive) { _%>
import jakarta.persistence.EntityManager;
<%_ } _%>
<%_ if (!databaseTypeCassandra) { _%>
import java.time.Instant;
<%_ } _%>
Expand Down Expand Up @@ -183,9 +180,11 @@ class UserResourceIT {
private UserMapper userMapper;
<%_ if (databaseTypeSql) { _%>

<%_ if (databaseTypeSql && reactive) { _%>
@Autowired
private EntityManager em;
<%_ } _%>
<%_ } _%>
<%_ if (cacheProviderAny) { _%>

@Autowired
Expand Down Expand Up @@ -222,7 +221,7 @@ class UserResourceIT {
* This is a static method, as tests for other entities might also need it,
* if they test an entity which has a required relationship to the User entity.
*/
public static <%= user.persistClass %> createEntity(<% if (databaseTypeSql) { %>EntityManager em<% } %>) {
public static <%= user.persistClass %> createEntity() {
<%= user.persistClass %> user = new <%= user.persistClass %>();
<%_ if (databaseTypeCassandra || (authenticationTypeOauth2 && !databaseTypeCouchbase)) { _%>
user.setId(UUID.randomUUID().toString());
Expand Down Expand Up @@ -262,12 +261,12 @@ class UserResourceIT {
/**
* Setups the database with one user.
*/
public static <%= user.persistClass %> initTestUser(UserRepository userRepository<% if (databaseTypeSql) { %>, EntityManager em<% } _%>) {
public static <%= user.persistClass %> initTestUser(UserRepository userRepository) {
<%_ if (databaseTypeSql && reactive) { _%>
userRepository.deleteAllUserAuthorities().block();
<%_ } _%>
userRepository.deleteAll()<% if (reactive) { %>.block()<% } %>;
<%= user.persistClass %> user = createEntity(<% if (databaseTypeSql ) { %>em<% } _%>);
<%= user.persistClass %> user = createEntity();
<%_ if (databaseTypeSql) { _%>
user.setLogin(DEFAULT_LOGIN);
user.setEmail(DEFAULT_EMAIL);
Expand All @@ -277,7 +276,7 @@ class UserResourceIT {

@BeforeEach
public void initTest() {
user = initTestUser(userRepository<% if (databaseTypeSql) { %>, em<% } _%>);
user = initTestUser(userRepository);
}
<%_ if (!authenticationTypeOauth2) { _%>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ filterTestableRelationships.forEach((relationship) => { _%>
// Add required entity
<%_ if (alreadyGeneratedEntities.indexOf(otherEntityName) == -1) { _%>
<%_ if (relationship.otherEntityUser) { /* TODO or other entity has no unique fields */ _%>
<%= relationship.otherEntity.persistClass %> <%= otherEntityName %> = <%= createEntityPrefix %><%= otherEntityNameCapitalized %>ResourceIT.createEntity(<% if (databaseTypeSql) { %>em<% } %>)<%= createEntityPostfix %>;
<%= relationship.otherEntity.persistClass %> <%= otherEntityName %> = <%= createEntityPrefix %><%= otherEntityNameCapitalized %>ResourceIT.createEntity(<% if (databaseTypeSql && !relationship.otherEntityUser) { %>em<% } %>)<%= createEntityPostfix %>;
<%_ if (databaseTypeSql && !reactive) { _%>
em.persist(<%= otherEntityName %>);
em.flush();
Expand Down Expand Up @@ -785,7 +785,7 @@ _%>
if (mapsIdUse) { _%>
// Add a new parent entity
<%_ if (alreadyGeneratedEntities.indexOf(otherEntityName) == -1) { _%>
<%= relationship.otherEntity.persistClass %> <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIT.create<% if (!relationship.otherEntityUser) { _%>Updated<%_ } %>Entity(<% if (databaseTypeSql) { %>em<% } %>);
<%= relationship.otherEntity.persistClass %> <%= otherEntityName %> = <%= otherEntityNameCapitalized %>ResourceIT.create<% if (!relationship.otherEntityUser) { _%>Updated<%_ } %>Entity(<% if (databaseTypeSql && !relationship.otherEntityUser) { %>em<% } %>);
<%_ if (databaseTypeSql && !reactive) { _%>
em.persist(<%= otherEntityName %>);
em.flush();
Expand Down Expand Up @@ -1223,12 +1223,12 @@ _%>
<%= relationship.otherEntity.persistClass %> <%= relationship.relationshipFieldName %>;
if (TestUtil.findAll(em, <%= relationship.otherEntity.persistClass %>.class).isEmpty()) {
<%= entityInstance %>Repository.saveAndFlush(<%= persistInstance %>);
<%= relationship.relationshipFieldName %> = <%= createEntityPrefix %><%= relationship.otherEntityNameCapitalized %>ResourceIT.createEntity(em);
<%= relationship.relationshipFieldName %> = <%= createEntityPrefix %><%= relationship.otherEntityNameCapitalized %>ResourceIT.createEntity(<%_ if (!relationship.otherEntityUser) { _%>em<%_ } _%>);
} else {
<%= relationship.relationshipFieldName %> = TestUtil.findAll(em, <%= relationship.otherEntity.persistClass %>.class).get(0);
}
<%_ } else { _%>
<%= relationship.otherEntity.persistClass %> <%= relationship.relationshipFieldName %> = <%= relationship.otherEntityNameCapitalized %>ResourceIT.createEntity(em);
<%= relationship.otherEntity.persistClass %> <%= relationship.relationshipFieldName %> = <%= relationship.otherEntityNameCapitalized %>ResourceIT.createEntity(<%_ if (!relationship.otherEntityUser) { _%>em<%_ } _%>);
<%_ } _%>
<%_ if(reactive) { _%>
<%= relationship.otherEntity.persistInstance %>Repository.<%= saveMethod %>(<%= relationship.relationshipFieldName %>)<%= callBlock %>;
Expand Down
Loading