use of com.developmentontheedge.be5.api.Response in project be5 by DevelopmentOnTheEdge.
the class QueryBuilderTest method generate.
@Test
public void generate() {
Response response = mock(Response.class);
component.generate(getSpyMockRequest("queryBuilder", ImmutableMap.of("sql", "select * from testtable limit 1", RestApiConstants.TIMESTAMP_PARAM, "" + new Date().getTime())), response, injector);
verify(response).sendAsJson(any(JsonApiModel.class));
}
use of com.developmentontheedge.be5.api.Response in project be5 by DevelopmentOnTheEdge.
the class StaticPageComponentTest method generateFoo.
@Test
public void generateFoo() throws Exception {
Response response = mock(Response.class);
String page = "foo.be";
component.generate(getMockRequest(page), response, injector);
verify(response).sendErrorAsJson(any(ErrorModel.class), any(Map.class));
}
use of com.developmentontheedge.be5.api.Response in project be5 by DevelopmentOnTheEdge.
the class ResponseTest method init.
@Before
public void init() throws Exception {
writer = mock(PrintWriter.class);
rawResponse = mock(HttpServletResponse.class);
when(rawResponse.getWriter()).thenReturn(writer);
response = new ResponseImpl(rawResponse);
}
use of com.developmentontheedge.be5.api.Response in project be5 by DevelopmentOnTheEdge.
the class HttpRequests method sendGet.
public static String sendGet(String url) {
try {
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestProperty("User-Agent", USER_AGENT);
int responseCode = con.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
return null;
}
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response.toString();
} catch (Exception e) {
throw Be5Exception.internal(e);
}
}
use of com.developmentontheedge.be5.api.Response in project be5 by DevelopmentOnTheEdge.
the class UserInfoComponentTest method generateSelectRolesAndSendNewStateNotAvailableRole.
@Test
public void generateSelectRolesAndSendNewStateNotAvailableRole() throws Exception {
Response response = mock(Response.class);
component.generate(getSpyMockRequest("", ImmutableMap.of("roles", RoleType.ROLE_ADMINISTRATOR)), response, injector);
verify(response).sendAsRawJson(new UserInfoComponent.State(true, TEST_USER, Collections.singletonList(RoleType.ROLE_ADMINISTRATOR), Collections.singletonList(RoleType.ROLE_ADMINISTRATOR), any(Date.class)));
}
Aggregations