This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • development/sharing/codeability-sharing-platform
1 result
Show changes
{
"exercise": {
"commingSoon": "demnächst verfügbar :-)",
"commingSoon": "demnächst verfügbar :-)",
"details": {
"details": "Details",
"rating": "Trefferqualität",
......
......@@ -17,7 +17,7 @@
"db": "Datenbank",
"elasticsearch": "Elasticsearch",
"elasticsearchRest": "Elasticsearch REST API",
"pluginHealthCheck": "Plugin Status"
"pluginHealthCheck": "Plugin Status"
},
"table": {
"service": "Dienst Name",
......
{
"exercise": {
"commingSoon": "comming soon",
"commingSoon": "comming soon",
"details": {
"details": "Details",
"rating": "Hit quality",
......
......@@ -17,8 +17,7 @@
"db": "Database",
"elasticsearch": "Elasticsearch",
"elasticsearchRest": "Elasticsearch REST API",
"pluginHealthCheck": "State of plugins"
"pluginHealthCheck": "State of plugins"
},
"table": {
"service": "Service name",
......
......@@ -3,11 +3,15 @@ package at.ac.uibk.gitsearch.web.rest;
import at.ac.uibk.gitsearch.GitsearchApp;
import at.ac.uibk.gitsearch.domain.Statistics;
import at.ac.uibk.gitsearch.repository.StatisticsRepository;
import at.ac.uibk.gitsearch.repository.gitlab.GitLabRepository;
import at.ac.uibk.gitsearch.repository.search.StatisticsSearchRepository;
import at.ac.uibk.gitsearch.service.GitlabService;
import at.ac.uibk.gitsearch.service.StatisticsService;
import at.ac.uibk.gitsearch.service.dto.StatisticsDTO;
import at.ac.uibk.gitsearch.service.mapper.StatisticsMapper;
import org.gitlab4j.api.GitLabApi;
import org.gitlab4j.api.ProjectApi;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
......@@ -25,12 +29,15 @@ import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import at.ac.uibk.gitsearch.security.AuthoritiesConstants;
import at.ac.uibk.gitsearch.security.jwt.TokenProvider.GitLabAccessInfo;
import static org.assertj.core.api.Assertions.assertThat;
import static org.elasticsearch.index.query.QueryBuilders.queryStringQuery;
import static org.hamcrest.Matchers.hasItem;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
......@@ -63,6 +70,10 @@ public class StatisticsResourceIT {
@Autowired
private StatisticsService statisticsService;
@Autowired
private GitLabRepository gitLabRepository;
/**
* This repository is mocked in the at.ac.uibk.gitsearch.repository.search test
* package.
......@@ -78,6 +89,9 @@ public class StatisticsResourceIT {
@Autowired
private MockMvc restStatisticsMockMvc;
@Autowired
private GitlabService gitlabService;
private Statistics statistics;
/**
......@@ -289,4 +303,46 @@ public class StatisticsResourceIT {
.andExpect(jsonPath("$.[*].downloads").value(hasItem(DEFAULT_DOWNLOADS)))
.andExpect(jsonPath("$.[*].exerciseID").value(hasItem(DEFAULT_EXERCISE_ID.intValue())));
}
@Test
@Transactional
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
public void getStatisticsByExerciseId() throws Exception {
// Initialize the database
statisticsRepository.saveAndFlush(statistics);
// Get the statistics and see if it coincides with the mock stats
assertEquals(statisticsService.findOneByExerciseID(statistics.getExerciseID()).get().getExerciseID(), statistics.getExerciseID());
}
@Test
@Transactional
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
public void createStatisticsByExerciseId() throws Exception {
// Initialize the database
statisticsRepository.saveAndFlush(statistics);
// Optional<GitLabAccessInfo> accessInfo = gitLabRepository.getGitLabAccessInfo();
// GitLabApi gitlabApi = gitLabRepository.getGitLabApi(accessInfo);
// ProjectApi projectApi = gitlabApi.getProjectApi();
// Integer id = projectApi.getProjects().get(0).getId();
// Get the statistics
// System.out.println("My request: ##################################################################");
// System.out.println(restStatisticsMockMvc.perform(get("/api/statistics/exercise/{id}", 3).with(csrf().asHeader())));
// restStatisticsMockMvc.perform(get("/api/statistics/exercise/{id}", 3).with(csrf().asHeader())).andExpect(status().isOk())
// .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
// .andExpect(jsonPath("$.exerciseID").value(3));
//assertEquals(true,gitlabService.repositoryExists("3"));
// Get the statistics and see if it coincides with the mock stats
assertEquals(statisticsService.findOneByExerciseID(statistics.getExerciseID()).get().getExerciseID(), statistics.getExerciseID());
}
}
......@@ -113,7 +113,7 @@ jhipster:
base-url: http://127.0.0.1:8080
security:
oauth2:
# TODO: audience seems not really relevant, could be omitted? It is identical with client-id above
# TODO: audience seems not really relevant, could be omitted? It is identical with client-id above
audience:
- 149276ac11138d9ba72fb3cd12815e3fa2f372866df0eac0f7d1aae5fdffea24
authentication:
......@@ -142,8 +142,8 @@ application:
highlight-pre: <mark><strong>
highlight-post: </strong></mark>
gitlab:
url: https://sharing.codeability-austria.uibk.ac.at/
generalAccessToken: zPxPmJE3UXAZJpBzxqej
url: https://sharing.codeability-austria.uibk.ac.at/
generalAccessToken: zPxPmJE3UXAZJpBzxqej
registeredPlugins:
- "http://localhost:8081/api/sharing/config" # may not be reachable for testing!
- "http://localhost:8082/api/sharingPluginConfig" # may not be reachable for testing!
- 'http://localhost:8081/api/sharing/config' # may not be reachable for testing!
- 'http://localhost:8082/api/sharingPluginConfig' # may not be reachable for testing!