how to mock nested autowired object in mockito code example

how to mock nested autowired object in mockito

1

1 Example

0
@Component
class TestedService { 

  @Autowired
  NestedService nestedService;

  String sayHello(String name){
     String result = "hello" + nestedService.toUpperCase(name)
  }
}

@Component
class NestedService {

  @Autowired
  MoreNestedService moreNestedService;

  String toUpperCase(String name){
        String nameWithDotAtTheEnd = moreNestedService.atDot(name);
        return nameWithDotAtTheEnd.toUpperCase();

  }

}
by on

Other Code Examples