Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
52 views

I have two routes defined in seperate classes. 1. public class FileRouter extends RouteBuilder { @Override public void configure() throws Exception { from("file:src/main/...
Sailaja Manchikanti's user avatar
0 votes
1 answer
59 views

My test cases are failing in controller class due to spring security. @PostMapping("/{username}") @PreAuthorize("hasRole('MEMBER') && #username == authentication....
Kollimarla Jagadeep's user avatar
-1 votes
1 answer
78 views

My predicate returns null pointer when it is executed. My test code: public class CompanyRepositoryTest { @Mock private EntityManager entityManager; @Mock private CriteriaBuilder ...
Arthur Bandeira's user avatar
1 vote
0 answers
334 views

Usually I use @MockBean annotation to any JPA repository services and works fine. But I tried to use @MockBean with RestTemplate object which was getting created in the Configuration class and it ...
PAMPA ROY's user avatar
0 votes
2 answers
193 views

I have a service class which uses a dependency - MyService @Service @ToString public class MyService{ Dependency dependency; public MyService(Dependency dependency) { System.out....
Sarthak's user avatar
  • 63
1 vote
0 answers
56 views

writing test cases for following code but not able to cover exceptionally part of completable feature CompletableFuture<Optional<A>> aFuture = CompletableFuture.supplyAsync(()->Optional....
vishvas chauhan's user avatar
0 votes
1 answer
199 views

The following classes reference each other crating a circular dependency: @AllArgsConstructor @Component public class A { private B b; public String doSomething() { return "...
j3d's user avatar
  • 9,832
1 vote
1 answer
72 views

Writing Junit unit testcase, I am trying to mock method callservice using Mockito. public CompletableFuture<String> getInfo(String something) { CompletableFuture<String> future = new ...
AktionScript's user avatar
0 votes
1 answer
1k views

I am getting null pointer exception while I am trying to mock @WebMvcTest(IMnJobManager.class) public class CMnJobManagerTest { @Autowired private MockMvc mockmvc; @Test public void ...
Swaraj Shekhar's user avatar
0 votes
2 answers
4k views

I design the test in JUnit using Mockito. The problem is in the following Test: @ExtendWith(MockitoExtension.class) class UserServiceTest { @InjectMocks private UserService userService; ...
caspian's user avatar
1 vote
1 answer
936 views

pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
Rajesh's user avatar
  • 11
0 votes
1 answer
480 views

I have to write Junit Test cases using Mockito. The method which I have to test is public method but internally it calles few private methods to get some DB data (Using EntityManager and Nativequery ...
tkz's user avatar
  • 23
0 votes
1 answer
5k views

@ExtendWith(value = SpringExtension.class) @TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class BaseAbstractTest { @MockBean protected TokenService tokenService; @...
skyho's user avatar
  • 1,963
0 votes
0 answers
563 views

Here is my producer send method that I'm writing a unit test for: public void send(final ReadingForecastRequest requestStub) { logger.info("{}::send()", getClass().getCanonicalName())...
sFishman's user avatar
  • 133
0 votes
1 answer
522 views

@Component public class SomeService { public void method1() { int batchSize = method2(); // some operations... } public void method2() { // something return 10; } Test class @...
sainadh's user avatar
  • 125
1 vote
1 answer
269 views

Lately I am writing junit test cases and I came across ZonedDateTime.now() works partially expected where the method which we try to write test case uses DozerBeanMapper for copying common fields. ...
Sachi97's user avatar
  • 41
0 votes
0 answers
115 views

I understand that the below error tells either I have to use all mocks or all original values. Invalid use of argument matchers! 0 matchers expected, 4 recorded: but for my code, I am using all mocks ...
LowCool's user avatar
  • 1,441
1 vote
0 answers
331 views

Java Class public class SendNotification { public NotificationProperty config; public PostDbClient postDbClient; public ObjectMapper objectMapper; public AmazonSNS snsClient; ...
ankursingh1000's user avatar
0 votes
1 answer
44 views

I have to test a Spring service which uses an Autowired object, see the following code: @Service public class MyService { @Autowired ExternalService externalService; public String ...
Lorenzo D'Isidoro's user avatar
0 votes
2 answers
1k views

Maybe a rather uncommon issue, but I'd like to mock certain Camel routes, in the JUnit setup method @BeforeEach void setUp() { } before the @Override public void configure() throws Exception { } is ...
Marian Klühspies's user avatar
0 votes
0 answers
246 views

I have this method to update a table in DB, it works correctly, until I create the unit test for it: public class ReferentialAdapter { private final JPAQueryFactory queryFactory; ...
Mirlo's user avatar
  • 674
1 vote
0 answers
324 views

I have two service classes (there are more, of course, but those two are relevant here), which are in use during an integration test. For test, I set up a mock (ConfigurationService) and stub two ...
kniffte's user avatar
  • 193
0 votes
1 answer
409 views

The issue is that the list of ids within the pageRequest object can be in any order. Is there a way to specify that below? The test fails since the pageRequest has a list of ids in a different order ...
Khanna111's user avatar
  • 3,961
0 votes
0 answers
24 views

This is the class structure: class A { private B b; A() { b = new B(); } public void foo() { b.anotherMethod(); } } Test class: class TestA { @Mock ...
aaaaa's user avatar
  • 465
1 vote
2 answers
905 views

I want to use any() inside then method. Here is my test code: @ExtendWith(MockitoExtension::class) internal class UserSignInProviderTest { @Mock lateinit var authApiClient: AuthApiClient ...
Kook's user avatar
  • 121
0 votes
1 answer
795 views

I'm super frustrated with a Kotlin/Mockito problem What I want to accomplish is very simple, I've an AuthorizationFilter on my springboot application and for test purposes I want to mock its behavior ...
Rafael Lima's user avatar
  • 3,585
1 vote
0 answers
2k views

I'm new to testing framework I have to test a function which have involves storing data from Db into list. Note: I don't have any POJO Class or Entity class for this. I'm just connecting to the ...
Rishabh's user avatar
  • 123
0 votes
2 answers
3k views

I am not able to understand why below two tests are not giving the same result. @Service public class SomeManager{ private final SomeDependency someDependency; @Autowired public ...
dark_prince's user avatar
1 vote
1 answer
517 views

Getting following exceptions when run all tests together but works as expected when executed individually org.mockito.exceptions.misusing.InvalidUseOfMatchersException: Misplaced or misused argument ...
Ankit Kadam's user avatar
-1 votes
1 answer
577 views

@GetMapping(value = "/abc") public ResponseDto<Map<String, FResponseDto>, Void> getFlightDetails(@RequestParam String fIds) { Map<String, FResponseDto> response = ...
Harsh Rao's user avatar
1 vote
0 answers
170 views

Hi I am very new to mockito framework. Can you please explain in lay man term why we need argument matchers and what is the need of any(), anyString() and what if I use a correct string instead of ...
Santrupta Dash's user avatar
13 votes
1 answer
7k views

Can you please explain when to use below annotations and when not to use those. I am pretty new to testing frameworks and confused with all the answers in the web. @Mock private Resource resource; @...
Santrupta Dash's user avatar
0 votes
1 answer
149 views

This is the method to write the JUnit test cases for public List<LoanApiCallEntity> getAllApiCallDetails() { return apiCallDetailsRepository.findAll(); } Inside the LoanApiCallEntity class ...
DARTHO's user avatar
  • 3
0 votes
1 answer
3k views

What I am trying to Do I am trying to test my class using cucumber and also make extent report on it. I am getting 2 errors in it 1 related to Mockito which is high priority and 2nd related to extent ...
Jahangeer Ayaz's user avatar
4 votes
1 answer
786 views

I created Dao Repository that uses jdbc for working with DB. I autowired this repository in my Service class. Then I try to autowire my service class in my test class. @SpringBootTest public class ...
Alexander Lopatin's user avatar
1 vote
1 answer
2k views

I have the following code snippets in my spring boot application: @Service public class UserServiceImpl implements UserService { private final UserRepository userRepository; public ...
monstereo's user avatar
  • 980
0 votes
1 answer
518 views

I have an object that looks like this: @Service @ConditionalOnProperty( name="name", havingValue = "true" ) public class MyClass{ @Autowired(required = false) ...
Rony Tesler's user avatar
  • 1,396
0 votes
0 answers
905 views

I'm getting an error when I step through my test code with @MockBean.thenReturn() in a debugger (Intellij Java 17). It works fine when it is executed outside the debugger though. Here is a ...
Paul C's user avatar
  • 8,429
0 votes
1 answer
237 views

Anyone knows how can I have normal spring beans injected into my MVC controller? @WebMvcTest(TaskController.class) class TasksManagerApplicationTests { @Spy // WRONG private TasksRepository taskDao; @...
Thomas Escolan's user avatar
2 votes
1 answer
11k views

When upgrading my app from Spring Boot 2.2 with JDK 11 to Spring Boot 2.5.5 with JDK 17, Mockito gives this error: Caused by: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang....
tm1701's user avatar
  • 7,723
1 vote
1 answer
2k views

@RequiredArgsConstructor public class GService { @Autowired private GRepository repository; private final List<GRule> rules; And my test class is like this; @ExtendWith(...
Abdu Muhammadal's user avatar
1 vote
1 answer
3k views

I have added a custom annotation on a method which is present inside a controller class. I have implemented Aspect class which is considering custom annotation as a point-cut. Once the execution ...
Stack Overflow's user avatar
2 votes
2 answers
2k views

Am using Mockito version 3.6.28 for Junit testing. Am getting Nullpointer Exception while calling the real method on the object. Its because of the dependency on the target object is not injected ...
Ansar Samad's user avatar
0 votes
1 answer
478 views

I wanted to stub a method that has 6 arguments without having to write any() each time So instead of when( service.method(any() , any() , any() , .. ).thenReturn( new ArrayList<>() ) ; is it ...
loser8's user avatar
  • 432
0 votes
5 answers
12k views

The main problem is that the convertToMultipartImage method in the AzureCloudStorageService class is returning null unexpectedly during testing, despite the mocking setup seeming correct. This ...
Feel free's user avatar
  • 1,103
0 votes
1 answer
1k views

I stuck since a couple of hours on a test method. I tried to reproduce a similar situation. I have a service who extend a abstract service with a utility method like this: public class MyService ...
Ersch's user avatar
  • 323
2 votes
0 answers
351 views

I know how to test websocket, like use WebSocketKing or Postman(2021/5/20), and it works good I have no idea about writing websocket in unit test usually, I use "SpringJUnit4ClassRunner" and ...
JosephHuang's user avatar
0 votes
0 answers
194 views

public class DgiQtyAction extends DispatchAction { private final Logger mLog = Logger.getLogger(this.getClass()); public ActionForward fnDgiQty(ActionMapping mapping, ActionForm form, ...
Nagarjun Jeyachandran's user avatar
0 votes
1 answer
819 views

I am using mockMvc for testing. How I can send PaymentOrderDto object value in mockMVc.perform which I can receive at controller method. Like PaymentOrderDto.setMid("m1") etc. @PostMapping(...
HARPREET SINGH's user avatar
0 votes
1 answer
598 views

When I run the test it shows the given error which I gave below. It shows Missing Method Invocation Exception Error. But I use that method in that test. I use Mockito to inject mockito. If anyone can ...
Md.Arif Shakil Nobin's user avatar