use of com.thoughtworks.go.plugin.api.response.GoApiResponse in project gocd by gocd.
the class SessionRequestProcessorTest method shouldHandleSessionNotFoundDuringGetFromSession.
@Test
public void shouldHandleSessionNotFoundDuringGetFromSession() {
String pluginId = "plugin-id-1";
String requestBody = "expected-request";
when(jsonMessageHandler.requestMessageSessionGetAndRemove(requestBody)).thenReturn(pluginId);
SessionRequestProcessor applicationAccessorSpy = spy(processor);
doReturn(null).when(applicationAccessorSpy).getUserSession();
GoApiResponse response = applicationAccessorSpy.process(pluginDescriptor, getGoPluginApiRequest("1.0", SessionRequestProcessor.GET_FROM_SESSION, requestBody));
assertThat(response.responseCode(), is(500));
}
use of com.thoughtworks.go.plugin.api.response.GoApiResponse in project gocd by gocd.
the class SessionRequestProcessorTest method shouldPutIntoSession.
@Test
public void shouldPutIntoSession() {
String pluginId = "plugin-id-1";
String requestBody = "expected-request";
Map<String, String> sessionData = new HashMap<>();
sessionData.put("k1", "v1");
sessionData.put("k2", "v2");
when(jsonMessageHandler.requestMessageSessionPut(requestBody)).thenReturn(new SessionData(pluginId, sessionData));
SessionRequestProcessor applicationAccessorSpy = spy(processor);
doReturn(session).when(applicationAccessorSpy).getUserSession();
GoApiResponse response = applicationAccessorSpy.process(pluginDescriptor, getGoPluginApiRequest("1.0", SessionRequestProcessor.PUT_INTO_SESSION, requestBody));
assertThat(response.responseCode(), is(200));
verify(session).setAttribute(pluginId, sessionData);
}
use of com.thoughtworks.go.plugin.api.response.GoApiResponse in project gocd by gocd.
the class SessionRequestProcessorTest method shouldHandleSessionNotFoundDuringPutIntoSession.
@Test
public void shouldHandleSessionNotFoundDuringPutIntoSession() {
String pluginId = "plugin-id-1";
String requestBody = "expected-request";
when(jsonMessageHandler.requestMessageSessionPut(requestBody)).thenReturn(new SessionData(pluginId, null));
SessionRequestProcessor applicationAccessorSpy = spy(processor);
doReturn(null).when(applicationAccessorSpy).getUserSession();
GoApiResponse response = applicationAccessorSpy.process(pluginDescriptor, getGoPluginApiRequest("1.0", SessionRequestProcessor.PUT_INTO_SESSION, requestBody));
assertThat(response.responseCode(), is(500));
}
Aggregations