use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class CookieItemTest method getFormattedElementOnCookieCountIsZero.
@Test
public void getFormattedElementOnCookieCountIsZero() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
HashSet<Cookie> cookieSet = new HashSet<>();
Mockito.when(mockContext.cookieCount()).thenReturn(0);
Mockito.when(mockContext.cookies()).thenReturn(cookieSet);
param.setContextData(mockContext);
String result = ELEMENT.getFormattedItem(param);
Assert.assertEquals("-", result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class CookieItemTest method getFormattedElementOnNotFound.
@Test
public void getFormattedElementOnNotFound() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
HashSet<Cookie> cookieSet = new HashSet<>();
String cookieValue = "cookieValue";
CookieImpl cookie = new CookieImpl("anotherCookieName", cookieValue);
cookieSet.add(cookie);
Mockito.when(mockContext.cookieCount()).thenReturn(1);
Mockito.when(mockContext.cookies()).thenReturn(cookieSet);
param.setContextData(mockContext);
String result = ELEMENT.getFormattedItem(param);
Assert.assertEquals("-", result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class CookieItemTest method getFormattedElement.
@Test
public void getFormattedElement() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext mockContext = Mockito.mock(RoutingContext.class);
HashSet<Cookie> cookieSet = new HashSet<>();
String cookieValue = "cookieValue";
CookieImpl cookie = new CookieImpl(COOKIE_NAME, cookieValue);
cookieSet.add(cookie);
Mockito.when(mockContext.cookieCount()).thenReturn(1);
Mockito.when(mockContext.cookies()).thenReturn(cookieSet);
param.setContextData(mockContext);
String result = ELEMENT.getFormattedItem(param);
Assert.assertEquals(cookieValue, result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class RequestProtocolItemTest method getFormattedElementOnVersionIsNull.
@Test
public void getFormattedElementOnVersionIsNull() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
HttpServerRequest request = Mockito.mock(HttpServerRequest.class);
param.setContextData(context);
Mockito.when(context.request()).thenReturn(request);
Mockito.when(request.version()).thenReturn(null);
String result = new RequestProtocolItem().getFormattedItem(param);
assertEquals("-", result);
}
use of org.apache.servicecomb.transport.rest.vertx.accesslog.AccessLogParam in project incubator-servicecomb-java-chassis by apache.
the class RequestProtocolItemTest method getFormattedElementOnRequestIsNull.
@Test
public void getFormattedElementOnRequestIsNull() {
AccessLogParam<RoutingContext> param = new AccessLogParam<>();
RoutingContext context = Mockito.mock(RoutingContext.class);
param.setContextData(context);
Mockito.when(context.request()).thenReturn(null);
String result = new RequestProtocolItem().getFormattedItem(param);
assertEquals("-", result);
}
Aggregations