public void scanAndPopulate(ApiActionHolder holder) throws ApiException { Map<String, Object> beans = context.getBeansWithAnnotation(ApiController.class); for (Object bean : beans.values()) { ApiController annotation = bean.getClass().getAnnotation(ApiController.class); final String controllerName = annotation.value(); if (StringUtils.isEmpty(controllerName)) { throw new ApiException("Controller name not found on bean " + bean.getClass().getName()); } final List<Method> actions = extractActions(bean); if (actions.size() > 0) { buildAndAddActions(bean, controllerName, actions, holder); } } }
@Test public void buscaOrgaosDisponivel() throws Exception { when(siorg.nomeDoOrgao( "http://estruturaorganizacional.dados.gov.br/doc/unidade-organizacional/404")) .thenReturn(of("")); controller.orgao("http://estruturaorganizacional.dados.gov.br/doc/unidade-organizacional/404"); verify(siorg) .nomeDoOrgao("http://estruturaorganizacional.dados.gov.br/doc/unidade-organizacional/404"); }
@Test public void pingDeveRetornarProfileEHorario() throws Exception { UserProfile profile = new UserProfile().withEmail("*****@*****.**"); given(userProfiles.get()).willReturn(profile); Ping ping = controller.ping(); assertThat(ping.getProfile(), is(profile)); assertThat(System.currentTimeMillis() - ping.getHorario(), is(lessThan(1000L))); }
@Test public void listaCategoriasDoVcgeDisponiveis() throws Exception { controller.vcge(); verify(vcge).get(); }
@Test public void listaOrgaosDisponiveis() throws Exception { controller.orgaos("Instituto"); verify(orgaos).get("Instituto"); }