vendredi 1 mai 2020

Spring boot integration tests fail just sometimes and only with gradle

Hello I have application with about 40 test. I am using Spring Boot, TestNG, Gradle and Hibernate. When I run all my tests using Idea IDE everything goes just fine and all the tests always pass. When I run the tests with gradle (even with debugging in idea) Some od these tests ale failing on assert. The strange thing is that it happens just sometimes and every time it's one of 3 different test methods. I guess that this problem is related to Hibernate (maybe caching)

The test method:

@Test
void findAllLanguages() throws Exception {
    Repository test = dbPopulator.createBase(generateUniqueString(), "ben");
    MvcResult mvcResult = performFindAll(test.getId()).andExpect(status().isOk()).andReturn();
    assertThat(decodeJson(mvcResult.getResponse().getContentAsString(), Set.class)).hasSize(2);
}

The dbPopulator.createBase(...) method creates some test data. The code of the method is:

@Transactional
public Repository createBase(String repositoryName, String username) {

    UserAccount userAccount = createUser(username);

    Repository repository = new Repository();
    repository.setName(repositoryName);
    repository.setCreatedBy(userAccount);

    en = createLanguage("en", repository);
    de = createLanguage("de", repository);

    permissionService.grantFullAccessToRepo(userAccount, repository);

    repositoryRepository.saveAndFlush(repository);
    entityManager.flush();
    entityManager.clear();

    return repository;
}

It is creating two languages (en, de). If i commit the transaction in the test right after the createBase execution in the test and break the thread. The data are correctly saved in DB! But when i try to get the data using languageRepository after this commit it returns just one language of these two (it is allways "en").

This is log of standard output:

    2020-05-01 10:08:21.701  INFO 73304 --- [    Test worker] o.s.t.c.transaction.TransactionContext   : Began transaction (2) for test context [DefaultTestContext@1e7aef1c testClass = LanguageControllerTest, testInstance = com.polygloat.controllers.LanguageControllerTest@9f12f7a, testMethod = findAllLanguages@LanguageControllerTest, testException = [null], mergedContextConfiguration = [WebMergedContextConfiguration@756a9643 testClass = LanguageControllerTest, locations = '{}', classes = '{class com.polygloat.Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@4b3fa0b3, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6baf64ac, [ImportsContextCustomizer@551455a5 key = [org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@7af0d48f, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@6a887c59, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@7aae4c61], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true]]; transaction manager [org.springframework.orm.jpa.JpaTransactionManager@3c5fc461]; rollback [true]
2020-05-01 10:08:21.701 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : select useraccoun0_.id as id1_7_, useraccoun0_.created_at as created_2_7_, useraccoun0_.updated_at as updated_3_7_, useraccoun0_.name as name4_7_, useraccoun0_.password as password5_7_, useraccoun0_.reset_password_code as reset_pa6_7_, useraccoun0_.role as role7_7_, useraccoun0_.third_party_auth_id as third_pa8_7_, useraccoun0_.third_party_auth_type as third_pa9_7_, useraccoun0_.username as usernam10_7_ from user_account useraccoun0_ where useraccoun0_.username=?
2020-05-01 10:08:21.701 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [VARCHAR] - [ben]
2020-05-01 10:08:21.702 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : insert into language (id, created_at, updated_at, abbreviation, name, repository_id) values (null, ?, ?, ?, ?, ?)
2020-05-01 10:08:21.702 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.702 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.702 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [VARCHAR] - [en]
2020-05-01 10:08:21.702 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [4] as [VARCHAR] - [en]
2020-05-01 10:08:21.702 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [5] as [BIGINT] - [null]
2020-05-01 10:08:21.702 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : insert into language (id, created_at, updated_at, abbreviation, name, repository_id) values (null, ?, ?, ?, ?, ?)
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [VARCHAR] - [de]
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [4] as [VARCHAR] - [de]
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [5] as [BIGINT] - [null]
2020-05-01 10:08:21.703 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : insert into permission (id, created_at, updated_at, invitation_id, repository_id, type, user_id) values (null, ?, ?, ?, ?, ?, ?)
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [BIGINT] - [null]
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [4] as [BIGINT] - [null]
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [5] as [VARCHAR] - [MANAGE]
2020-05-01 10:08:21.703 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [6] as [BIGINT] - [2]
2020-05-01 10:08:21.704 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : insert into repository (id, created_at, updated_at, created_by_id, description, name) values (null, ?, ?, ?, ?, ?)
2020-05-01 10:08:21.704 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.704 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.704 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [BIGINT] - [2]
2020-05-01 10:08:21.704 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [4] as [VARCHAR] - [null]
2020-05-01 10:08:21.704 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [5] as [VARCHAR] - [3a3d3ec5-e8eb-4256-ac10-9d4b87f38e21]
2020-05-01 10:08:21.704 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : update language set updated_at=?, abbreviation=?, name=?, repository_id=? where id=?
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [VARCHAR] - [en]
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [VARCHAR] - [en]
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [4] as [BIGINT] - [8]
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [5] as [BIGINT] - [16]
2020-05-01 10:08:21.705 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : update language set updated_at=?, abbreviation=?, name=?, repository_id=? where id=?
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [VARCHAR] - [de]
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [VARCHAR] - [de]
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [4] as [BIGINT] - [8]
2020-05-01 10:08:21.705 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [5] as [BIGINT] - [17]
2020-05-01 10:08:21.705 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : update permission set updated_at=?, invitation_id=?, repository_id=?, type=?, user_id=? where id=?
2020-05-01 10:08:21.706 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [TIMESTAMP] - [Fri May 01 10:08:21 CEST 2020]
2020-05-01 10:08:21.706 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [2] as [BIGINT] - [null]
2020-05-01 10:08:21.706 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [3] as [BIGINT] - [8]
2020-05-01 10:08:21.706 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [4] as [VARCHAR] - [MANAGE]
2020-05-01 10:08:21.706 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [5] as [BIGINT] - [2]
2020-05-01 10:08:21.706 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [6] as [BIGINT] - [8]
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 1 of 13 in additional filter chain; firing Filter: 'WebAsyncManagerIntegrationFilter'
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 2 of 13 in additional filter chain; firing Filter: 'SecurityContextPersistenceFilter'
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 3 of 13 in additional filter chain; firing Filter: 'HeaderWriterFilter'
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 4 of 13 in additional filter chain; firing Filter: 'CorsFilter'
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 5 of 13 in additional filter chain; firing Filter: 'LogoutFilter'
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', GET]
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/repository/8/languages'; against '/logout'
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', POST]
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /api/repository/8/languages' doesn't match 'POST /logout'
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', PUT]
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /api/repository/8/languages' doesn't match 'PUT /logout'
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.s.web.util.matcher.OrRequestMatcher  : Trying to match using Ant [pattern='/logout', DELETE]
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Request 'GET /api/repository/8/languages' doesn't match 'DELETE /logout'
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.s.web.util.matcher.OrRequestMatcher  : No matches found
2020-05-01 10:08:21.707 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 6 of 13 in additional filter chain; firing Filter: 'JwtTokenFilter'
2020-05-01 10:08:21.708 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : select useraccoun0_.id as id1_7_0_, useraccoun0_.created_at as created_2_7_0_, useraccoun0_.updated_at as updated_3_7_0_, useraccoun0_.name as name4_7_0_, useraccoun0_.password as password5_7_0_, useraccoun0_.reset_password_code as reset_pa6_7_0_, useraccoun0_.role as role7_7_0_, useraccoun0_.third_party_auth_id as third_pa8_7_0_, useraccoun0_.third_party_auth_type as third_pa9_7_0_, useraccoun0_.username as usernam10_7_0_ from user_account useraccoun0_ where useraccoun0_.id=?
2020-05-01 10:08:21.708 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [2]
2020-05-01 10:08:21.708 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 7 of 13 in additional filter chain; firing Filter: 'ApiAuthFilter'
2020-05-01 10:08:21.708 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 8 of 13 in additional filter chain; firing Filter: 'RequestCacheAwareFilter'
2020-05-01 10:08:21.708 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 9 of 13 in additional filter chain; firing Filter: 'SecurityContextHolderAwareRequestFilter'
2020-05-01 10:08:21.708 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 10 of 13 in additional filter chain; firing Filter: 'AnonymousAuthenticationFilter'
2020-05-01 10:08:21.708 DEBUG 73304 --- [    Test worker] o.s.s.w.a.AnonymousAuthenticationFilter  : SecurityContextHolder not populated with anonymous token, as it already contained: 'org.springframework.security.authentication.UsernamePasswordAuthenticationToken@e4dc8860: Principal: UserAccount(id=2, username=ben, name=ben); Credentials: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: com.polygloat.security.JwtTokenProvider$$Lambda$1117/0x00000008016ae840@5d1c369d'
2020-05-01 10:08:21.708 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 11 of 13 in additional filter chain; firing Filter: 'SessionManagementFilter'
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] s.CompositeSessionAuthenticationStrategy : Delegating to org.springframework.security.web.authentication.session.ChangeSessionIdAuthenticationStrategy@3984889d
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 12 of 13 in additional filter chain; firing Filter: 'ExceptionTranslationFilter'
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages at position 13 of 13 in additional filter chain; firing Filter: 'FilterSecurityInterceptor'
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/repository/8/languages'; against '/api/public/**'
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/repository/8/languages'; against '/webjars/**'
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/repository/8/languages'; against '/swagger-ui.html'
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/repository/8/languages'; against '/swagger-resources/**'
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/repository/8/languages'; against '/v2/api-docs'
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.u.matcher.AntPathRequestMatcher  : Checking match of request : '/api/repository/8/languages'; against '/api/**'
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.a.i.FilterSecurityInterceptor    : Secure object: FilterInvocation: URL: /api/repository/8/languages; Attributes: [authenticated]
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.a.i.FilterSecurityInterceptor    : Previously Authenticated: org.springframework.security.authentication.UsernamePasswordAuthenticationToken@e4dc8860: Principal: UserAccount(id=2, username=ben, name=ben); Credentials: [PROTECTED]; Authenticated: true; Details: null; Granted Authorities: com.polygloat.security.JwtTokenProvider$$Lambda$1117/0x00000008016ae840@5d1c369d
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.access.vote.AffirmativeBased       : Voter: org.springframework.security.web.access.expression.WebExpressionVoter@7500e765, returned: 1
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.a.i.FilterSecurityInterceptor    : Authorization successful
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.s.w.a.i.FilterSecurityInterceptor    : RunAsManager did not change Authentication object
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] o.s.security.web.FilterChainProxy        : /api/repository/8/languages reached end of additional filter chain; proceeding with original chain
2020-05-01 10:08:21.709 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : select language0_.id as id1_2_, language0_.created_at as created_2_2_, language0_.updated_at as updated_3_2_, language0_.abbreviation as abbrevia4_2_, language0_.name as name5_2_, language0_.repository_id as reposito6_2_ from language language0_ left outer join repository repository1_ on language0_.repository_id=repository1_.id where repository1_.id=?
2020-05-01 10:08:21.709 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [8]
2020-05-01 10:08:21.710 DEBUG 73304 --- [    Test worker] org.hibernate.SQL                        : select repository0_.id as id1_4_0_, repository0_.created_at as created_2_4_0_, repository0_.updated_at as updated_3_4_0_, repository0_.created_by_id as created_6_4_0_, repository0_.description as descript4_4_0_, repository0_.name as name5_4_0_, useraccoun1_.id as id1_7_1_, useraccoun1_.created_at as created_2_7_1_, useraccoun1_.updated_at as updated_3_7_1_, useraccoun1_.name as name4_7_1_, useraccoun1_.password as password5_7_1_, useraccoun1_.reset_password_code as reset_pa6_7_1_, useraccoun1_.role as role7_7_1_, useraccoun1_.third_party_auth_id as third_pa8_7_1_, useraccoun1_.third_party_auth_type as third_pa9_7_1_, useraccoun1_.username as usernam10_7_1_ from repository repository0_ left outer join user_account useraccoun1_ on repository0_.created_by_id=useraccoun1_.id where repository0_.id=?
2020-05-01 10:08:21.710 TRACE 73304 --- [    Test worker] o.h.type.descriptor.sql.BasicBinder      : binding parameter [1] as [BIGINT] - [8]
2020-05-01 10:08:21.711 DEBUG 73304 --- [    Test worker] o.s.s.w.header.writers.HstsHeaderWriter  : Not injecting HSTS header since it did not match the requestMatcher org.springframework.security.web.header.writers.HstsHeaderWriter$SecureRequestMatcher@4e984973
2020-05-01 10:08:21.711 DEBUG 73304 --- [    Test worker] o.s.s.w.a.ExceptionTranslationFilter     : Chain processed normally
2020-05-01 10:08:21.711 DEBUG 73304 --- [    Test worker] s.s.w.c.SecurityContextPersistenceFilter : SecurityContextHolder now cleared, as request processing completed
2020-05-01 10:08:21.718  INFO 73304 --- [    Test worker] o.s.t.c.transaction.TransactionContext   : Rolled back transaction for test: [DefaultTestContext@1e7aef1c testClass = LanguageControllerTest, testInstance = com.polygloat.controllers.LanguageControllerTest@9f12f7a, testMethod = findAllLanguages@LanguageControllerTest, testException = java.lang.AssertionError: 
Expected size:<2> but was:<1> in:
<[{"abbreviation"="en", "id"=16, "name"="en"}]>, mergedContextConfiguration = [WebMergedContextConfiguration@756a9643 testClass = LanguageControllerTest, locations = '{}', classes = '{class com.polygloat.Application}', contextInitializerClasses = '[]', activeProfiles = '{}', propertySourceLocations = '{}', propertySourceProperties = '{org.springframework.boot.test.context.SpringBootTestContextBootstrapper=true}', contextCustomizers = set[org.springframework.boot.test.autoconfigure.properties.PropertyMappingContextCustomizer@4b3fa0b3, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverContextCustomizerFactory$Customizer@6baf64ac, [ImportsContextCustomizer@551455a5 key = [org.springframework.boot.test.autoconfigure.web.servlet.MockMvcAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebClientAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcWebDriverAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration, org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcSecurityConfiguration]], org.springframework.boot.test.context.filter.ExcludeFilterContextCustomizer@7af0d48f, org.springframework.boot.test.json.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer@6a887c59, org.springframework.boot.test.mock.mockito.MockitoContextCustomizer@0, org.springframework.boot.test.web.client.TestRestTemplateContextCustomizer@7aae4c61], resourceBasePath = 'src/main/webapp', contextLoader = 'org.springframework.boot.test.context.SpringBootContextLoader', parent = [null]], attributes = map['org.springframework.test.context.web.ServletTestExecutionListener.activateListener' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.populatedRequestContextHolder' -> true, 'org.springframework.test.context.web.ServletTestExecutionListener.resetRequestContextHolder' -> true]]

I am really confused about this, because it seems that Hibernate is really executing the query that should return both languages. I am also using H2 database. Could it be some kind of issue related to this DB? If I execute the exactly same SQL as Hibernate runs (according to log) it returns correct result:

select language0_.id as id1_2_, language0_.created_at as created_2_2_, language0_.updated_at as updated_3_2_, language0_.abbreviation as abbrevia4_2_, language0_.name as name5_2_, language0_.repository_id as reposito6_2_ from language language0_ left outer join repository repository1_ on language0_.repository_id=repository1_.id where repository1_.id=8

Any Ideas? Thanks for any comment! :)

Aucun commentaire:

Enregistrer un commentaire