79400001

Date: 2025-01-30 13:09:02
Score: 0.5
Natty:
Report link

Managed to get it working by making removing @EnableReactiveMongoRepositories

 */
@SpringBootApplication
// @EnableReactiveMongoRepositories
public class AriesApplication {

    public static void main(String[] args) {

        SpringApplication.run(AriesApplication.class, args);

    }

}


and changing TestRepositoryConfig to

@TestConfiguration
@@EnableAutoConfiguration(exclude = { MongoReactiveRepositoriesAutoConfiguration.class })

public class RepositoryTestConfig {
    private final User mockAuthor = new User(new ObjectId("6795b64f525959be00d07c0b"), "rbelmont", "Richter", "Belmont",
            "[email protected]", false);
    private final Post mockPost = new Post("how to gitgood part two", "you just have to grind 3 hours everyday",
            mockAuthor.getUsername(), LocalDateTime.now(), LocalDateTime.now(), false, false);

    @Bean
    @Profile("mock")
    public UserRepository userRepository() {
        return mock(UserRepository.class);
    }

    @Bean
    @Profile("mock")
    public PostRepository postRepository() {
        PostRepository postRepository = mock(PostRepository.class);
        when(postRepository.save(any())).thenReturn(Mono.just(mockPost));
        return postRepository;
    }

}


Reasons:
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @EnableReactiveMongoRepositoriesand
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: lulski gonzales