I am trying to write an end to end test I want to invoke my enpoint with WebTestClient which invoke a component which has a a webClient as a property.The problem is I have a NullPointerException when to the Builder even if the injection is ok. This is my test setup
@Mock
private WebClient.Builder webBuilder;
@Mock
WebClient webclient;
@Mock
BidProperties bidProperties;
@InjectMocks
private BidderProcessorService bidderProcessorService;
private BidsResource bidsResource;
@Before
public void setUp() {
PowerMockito.when(webBuilder.defaultHeader(HttpHeaders.CONTENT_TYPE, "application/json")).thenReturn(webBuilder);
PowerMockito.when(webBuilder.defaultHeader(HttpHeaders.CONTENT_TYPE, "application/json").build()).thenReturn(webclient);
bidderProcessorService = PowerMockito.spy(new BidderProcessorService(bidProperties, webBuilder));
bidsResource=PowerMockito.spy(new BidsResource(bidderProcessorService));
}
and this is my constructor to the service
*/
public BidderProcessorService(BidProperties bidProperties, WebClient.Builder builder) {
webclient = builder.defaultHeader(HttpHeaders.CONTENT_TYPE, "application/json").build();
this.bidProperties = bidProperties;
}
Aucun commentaire:
Enregistrer un commentaire