Search in sources :

Example 21 with MockInterceptor

use of com.opensymphony.xwork2.mock.MockInterceptor in project aws-cloud-meta by prisma-capacity.

the class ECSMetaDataReaderTest method testSuccessfulRead.

@Test
void testSuccessfulRead() throws IOException {
    val interceptor = new MockInterceptor();
    val url = "http://example.com";
    interceptor.addRule().get(url + "/task").respond(RESPONSE);
    val client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
    when(objectMapper.readValue(RESPONSE, TaskMetaData.class)).thenReturn(taskMetaData);
    val uut = new ECSMetaDataReader(url, client, objectMapper);
    val result = uut.readTaskMetaData();
    assertTrue(result.isPresent());
    verify(objectMapper).readValue(RESPONSE, TaskMetaData.class);
}
Also used : lombok.val(lombok.val) MockInterceptor(okhttp3.mock.MockInterceptor) Test(org.junit.jupiter.api.Test)

Example 22 with MockInterceptor

use of com.opensymphony.xwork2.mock.MockInterceptor in project aws-cloud-meta by prisma-capacity.

the class ECSMetaDataReaderTest method testUnsuccessfulRead.

@Test
void testUnsuccessfulRead() {
    val interceptor = new MockInterceptor();
    val url = "http://example.com";
    interceptor.addRule().get(url + "/task").respond(404);
    val client = new OkHttpClient.Builder().addInterceptor(interceptor).build();
    val uut = new ECSMetaDataReader(url, client, objectMapper);
    val result = uut.readTaskMetaData();
    assertFalse(result.isPresent());
    verifyNoInteractions(objectMapper);
}
Also used : lombok.val(lombok.val) MockInterceptor(okhttp3.mock.MockInterceptor) Test(org.junit.jupiter.api.Test)

Aggregations

MockInterceptor (okhttp3.mock.MockInterceptor)13 Before (org.junit.Before)9 MockInterceptor (com.opensymphony.xwork2.mock.MockInterceptor)7 InterceptorMapping (com.opensymphony.xwork2.config.entities.InterceptorMapping)5 OkHttpClient (okhttp3.OkHttpClient)5 ActionProxy (com.opensymphony.xwork2.ActionProxy)4 lombok.val (lombok.val)4 Test (org.junit.jupiter.api.Test)4 InterceptorStackConfig (com.opensymphony.xwork2.config.entities.InterceptorStackConfig)3 PackageConfig (com.opensymphony.xwork2.config.entities.PackageConfig)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 HttpUrl (okhttp3.HttpUrl)3 Builder (okhttp3.HttpUrl.Builder)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ConfigurationProvider (com.opensymphony.xwork2.config.ConfigurationProvider)2 Map (java.util.Map)2 StrutsXmlConfigurationProvider (org.apache.struts2.config.StrutsXmlConfigurationProvider)2 JsonCodecV2 (org.eclipse.emfcloud.modelserver.emf.common.codecs.JsonCodecV2)2 Mock (com.mockobjects.dynamic.Mock)1