Spring Boot Microservices JWT JUnit Test Issue

I have a problem about solving JwtGrantedAuthoritiesConverter in order service after defining preauthorize annotation in some methods of Order Controller.
After I wrote the test shown below, I tried to run it but I got this issue shown below as well.
I also shared my repo as a link.
How can I fix it?
Here is the test method shown below
@Test
public void test_WhenPlaceOrder_DoPayment_Success() throws Exception {
     OrderRequest orderRequest = getMockOrderRequest();
     MvcResult mvcResult
              = mockMvc.perform(MockMvcRequestBuilders.post("/order/placeOrder")
                            .with(jwt().authorities(new SimpleGrantedAuthority("USER")))
                            .contentType(MediaType.APPLICATION_JSON_VALUE)
                            .content(objectMapper.writeValueAsString(orderRequest))
              ).andExpect(MockMvcResultMatchers.status().isOk())
              .andReturn();
    
    String orderId = mvcResult.getResponse().getContentAsString();
    
    Optional<Order> order = orderRepository.findById(Long.valueOf(orderId));
            assertTrue(order.isPresent());
    
   Order o = order.get();
   assertEquals(Long.parseLong(orderId), o.getId());
   assertEquals("PLACED", o.getOrderStatus());
   assertEquals(orderRequest.getTotalAmount(), o.getAmount());
   assertEquals(orderRequest.getQuantity(), o.getQuantity());
    
}

Here is the error shown below.
    java.lang.NoClassDefFoundError: org/springframework/security/oauth2/server/resource/authentication/JwtGrantedAuthoritiesConverter
    Caused by: java.lang.ClassNotFoundException: org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter

Here is the repo link : https://github.com/Rapter1990/microservicecoursedailybuffer
GitHub
Spring Boot Microservice Example. Contribute to Rapter1990/microservicecoursedailybuffer development by creating an account on GitHub.
GitHub - Rapter1990/microservicecoursedailybuffer: Spring Boot Micr...
Was this page helpful?