Revert additional profile, add global Mock for EntityService<DummyEntity>
Two key changes: 1. Add a factory method to create the EntityService with the DummyEntity, so that all other test cases can initialize this Bean. This solves the IllegalStateException reported in this ticket. 2. Use @Autowire instead of @MockBean to use the new factory method. That resolves the known issue that the caching test case does not work because of different RoomRepositories being created for the PermissionEvaluatorAdvice and the EntityService. This makes all tests runnable again. My current theory is that due to the fact that we have at least two EntityServices (one created by the DefaultEntityServiceImplTest, and now one by this test). The @MockBean annotation could be throwing out the previous EntityService, since according to documentation, it replaces existing Beans with the same type. This could lead to a situation where, initially, the PermissionEvaluatorAdvice and the DefaultEntityService share the same RoomRepository. But after the @MockBean replacement occurs, the EntityService is recreated with a different RoomRepository, while the Advice keeps its initial RoomRepository, leading to testing failures in the testCaching test case.
Showing
Please register or sign in to comment