use of com.tvd12.ezyfoxserver.support.test.data.GreetResponse in project ezyfox-server by youngmonkeys.
the class EzyRequestHandlersImplementerTest method test.
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void test() {
// given
EzyAppContext context = mock(EzyAppContext.class);
EzySession session = mock(EzyAbstractSession.class);
EzyUser user = new EzySimpleUser();
EzyUserSessionEvent event = new EzySimpleUserSessionEvent(user, session);
EzyRequestHandlerImplementer.setDebug(true);
EzyRequestHandlersImplementer implementer = new EzyRequestHandlersImplementer();
EzyResponseFactory responseFactory = mock(EzyResponseFactory.class);
EzyObjectResponse objectResponse = mock(EzyObjectResponse.class);
when(responseFactory.newObjectResponse()).thenReturn(objectResponse);
when(objectResponse.command("Big/Hello6")).thenReturn(objectResponse);
when(objectResponse.data(new GreetResponse("Hello Dzung!"))).thenReturn(objectResponse);
when(objectResponse.session(any())).thenReturn(objectResponse);
doNothing().when(objectResponse).execute();
implementer.setResponseFactory(responseFactory);
EzyFeatureCommandManager featureCommandManager = new EzyFeatureCommandManager();
EzyRequestCommandManager requestCommandManager = new EzyRequestCommandManager();
implementer.setFeatureCommandManager(featureCommandManager);
implementer.setRequestCommandManager(requestCommandManager);
Map<String, EzyUserRequestHandler> handlers = implementer.implement(Collections.singletonList(new HelloController()));
for (EzyUserRequestHandler handler : handlers.values()) {
handler.handle(context, event, new GreetRequest("Dzung"));
}
EzyRequestHandlerImplementer.setDebug(false);
implementer = new EzyRequestHandlersImplementer();
implementer.setFeatureCommandManager(featureCommandManager);
implementer.setRequestCommandManager(requestCommandManager);
// when
handlers = implementer.implement(Collections.singletonList(new HelloController()));
// then
Asserts.assertTrue(handlers.containsKey("Big/Hello"));
verify(responseFactory, times(1)).newObjectResponse();
verify(objectResponse, times(1)).command("Big/Hello6");
verify(objectResponse, times(1)).data(new GreetResponse("Hello Dzung!"));
}
use of com.tvd12.ezyfoxserver.support.test.data.GreetResponse in project ezyfox-server by youngmonkeys.
the class HelloController2 method greet.
@EzyDoHandle("Hello")
public void greet(@EzyRequestData GreetRequest request, EzyUser user, EzySession session, Integer nothing) {
GreetResponse response = new GreetResponse("Hello " + request.getWho() + "!");
System.out.println("HelloController::Big/Hello response: " + response);
}
use of com.tvd12.ezyfoxserver.support.test.data.GreetResponse in project ezyfox-server by youngmonkeys.
the class HelloController2 method greet.
@EzyDoHandle("Hello")
public void greet(GreetRequest request, EzyUser user, EzySession session) {
GreetResponse response = new GreetResponse("Hello " + request.getWho() + "!");
System.out.println("HelloController::Big/Hello response: " + response);
}
use of com.tvd12.ezyfoxserver.support.test.data.GreetResponse in project ezyfox-examples by tvd12.
the class HelloWorldRpcClientExample method main.
public static void main(String[] args) throws Exception {
QuickRpcClient client = QuickRpcClient.builder().scan("com.tvd12.quick.rpc.examples.hello_world.data").build();
GreetResponse response = client.call(new GreetRequest("World"), GreetResponse.class);
System.out.println(response.getMessage());
}
use of com.tvd12.ezyfoxserver.support.test.data.GreetResponse in project ezyfox-server by youngmonkeys.
the class HelloController method greet.
@EzyDoHandle("Hello2")
public void greet(@EzyRequestData GreetRequest request, EzyUser user, EzySession session, Integer nothing) {
GreetResponse response = new GreetResponse("Hello " + request.getWho() + "!");
System.out.println("HelloController::Big/Hello response: " + response);
}
Aggregations