We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to write a unit test for sms method by mocking ProducerTemplate.
sms
@Path("/") public class SmsResource { @Inject ProducerTemplate producerTemplate; @POST @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/sms") public Message sms() { return producerTemplate .requestBody("twilio://message/creator?from=RAW(+15005550006)&to=RAW(+15005550006)&body=TestMessage", null, Message.class); } }
I've tried that but it doesn't work.
@QuarkusTest class SmsControllerTest { @Inject SmsResource smsResource; @InjectMocks ProducerTemplate producerTemplate; @BeforeEach public void setup() throws Exception { MockitoAnnotations.openMocks(this); } @Test void sendSms() throws Exception { Message message = Message.fromJson("{\"body\":\"Test Message\",\"status\": \"queued\"}", new ObjectMapper()); when(producerTemplate.requestBody(anyString(), null, Message.class)).thenReturn(message); smsResource.sms(); } }
The text was updated successfully, but these errors were encountered:
Which part does not work as expected and what do you expect actually?
Sorry, something went wrong.
Closing as stale
No branches or pull requests
I want to write a unit test for
sms
method by mocking ProducerTemplate.I've tried that but it doesn't work.
The text was updated successfully, but these errors were encountered: