### Question:
ScopeService { public String getScopeByName(String scopeName) throws OAuthException { String jsonString = null; Scope scope = DBManagerFactory.getInstance().findScope(scopeName); if (scope != null) { ObjectMapper mapper = new ObjectMapper(); try { jsonString = mapper.writeValueAsString(scope); } catch (JsonGenerationException e) { log.error("cannot load scopes", e); throw new OAuthException(e, null, HttpResponseStatus.BAD_REQUEST); } catch (JsonMappingException e) { log.error("cannot load scopes", e); throw new OAuthException(e, null, HttpResponseStatus.BAD_REQUEST); } catch (IOException e) { log.error("cannot load scopes", e); throw new OAuthException(e, null, HttpResponseStatus.BAD_REQUEST); } } else { throw new OAuthException(SCOPE_NOT_EXIST, HttpResponseStatus.NOT_FOUND); } return jsonString; }  String registerScope(HttpRequest req); String getScopes(HttpRequest req); String getValidScope(String scope, String clientId); String getValidScopeByScope(String scope, String storedScope); boolean scopeAllowed(String scope, String allowedScopes); int getExpiresIn(String tokenGrantType, String scope); String updateScope(HttpRequest req, String scopeName); String deleteScope(String scopeName); String getScopeByName(String scopeName);  }### Answer:
@Test public void when_GET_non_existing_scope_by_name_return_error_scope_does_not_exist_message() throws Exception { String scope = "scope"; willReturn(null).given(DBManagerFactory.dbManager).findScope(scope); String errorMessage = null; HttpResponseStatus errorStatus = null; try { service.getScopeByName(scope); } catch (OAuthException e) { errorMessage = e.getMessage(); errorStatus = e.getHttpStatus(); } assertEquals(errorMessage, ScopeService.SCOPE_NOT_EXIST); assertEquals(errorStatus, HttpResponseStatus.NOT_FOUND); }