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

Skip to content
Snippets Groups Projects
Commit 1232ec4f authored by Michael Breu's avatar Michael Breu
Browse files

fixing tests

parent c163eb7a
Branches
1 merge request!211Merge new meta data indexing
......@@ -126,12 +126,12 @@ public class ElasticSearchManagementResource {
/**
* this is a simple wrapper class to enable correct json deserialisation.
*
* @author Micha
* @author Michael Breu
*
*/
protected class IndicesRecordWrapper {
protected static class IndicesRecordWrapper {
IndicesRecord indexRecord;
protected IndicesRecord indexRecord;
protected IndicesRecordWrapper(IndicesRecord indexRecord) {
super();
......@@ -178,6 +178,13 @@ public class ElasticSearchManagementResource {
public String getCreationDateString() {
return indexRecord.creationDateString();
}
// public IndicesRecord getIndexRecord() {
// return indexRecord;
// }
// public void setIndexRecord(IndicesRecord indexRecord) {
// this.indexRecord = indexRecord;
// }
}
/**
......
package at.ac.uibk.gitsearch.web.rest;
import static org.assertj.core.api.Assertions.assertThat;
import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import at.ac.uibk.gitsearch.GitsearchApp;
import at.ac.uibk.gitsearch.repository.search.testESService.ElasticSearchTestConfiguration;
import at.ac.uibk.gitsearch.security.AuthoritiesConstants;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.elasticsearch.node.NodeValidationException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;
/**
* Integration tests for the {@link StatisticsResource} REST controller.
*/
@SpringBootTest(classes = GitsearchApp.class)
@ExtendWith(MockitoExtension.class)
@AutoConfigureMockMvc
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
class ElastictSearchManagementResourceIT {
@Autowired
private MockMvc restStatisticsMockMvc;
@Autowired
ElasticSearchTestConfiguration elasticSearchTestConfiguration;
static ElasticSearchTestConfiguration staticElasticSearchTestConfiguration;
@BeforeEach // must be started as BeforeEach, in order to autowire the ElasticSearchTestConfiguration
@Timeout(value = 2, unit = TimeUnit.MINUTES)
void setUpESServer() throws IOException, NodeValidationException {
if (staticElasticSearchTestConfiguration == null) {
elasticSearchTestConfiguration.startTestNode();
staticElasticSearchTestConfiguration = elasticSearchTestConfiguration;
}
}
@AfterAll
public static void shutDownESServer() {
if (staticElasticSearchTestConfiguration != null) {
staticElasticSearchTestConfiguration.stopTestContainer();
staticElasticSearchTestConfiguration = null;
}
}
@Test
@Transactional
@WithMockUser(authorities = AuthoritiesConstants.ADMIN)
void getIndices() throws Exception {
restStatisticsMockMvc
.perform(get("/api/esManagement/indices").with(csrf().asHeader()).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().is2xxSuccessful())
.andExpect(
TestUtil.testResult(
List.class,
r -> {
assertThat(r).isNotEmpty().allMatch(e -> true);
}
)
);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment