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

Skip to content
Snippets Groups Projects
Commit ac32de7d authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Further Fixing Tests

parent 42426d07
1 merge request!17Initial Merge to Prepare Release 1.0.0
......@@ -11,7 +11,9 @@ import java.io.InputStream;
import org.apache.logging.log4j.LogManager;
import org.codeability.sharing.plugins.api.SharingPluginConfig;
import org.codeability.sharing.plugins.api.SharingPluginConfig.Action;
import org.elasticsearch.node.NodeValidationException;
import org.junit.Assert;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
......@@ -26,6 +28,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import at.ac.uibk.gitsearch.GitsearchApp;
import at.ac.uibk.gitsearch.repository.search.testESService.ElasticSearchTestServerConfiguration;
import at.ac.uibk.gitsearch.service.PluginManagementService.PluginConfigWrapper;
import at.ac.uibk.gitsearch.service.PluginManagementService.PluginConfigWrapper.ActionWrapper;
import at.ac.uibk.gitsearch.service.dto.SearchInputDTO;
......@@ -42,57 +45,14 @@ public class SearchServiceIT {
@Autowired
private SearchService searchService;
private PluginConfigWrapper config;
@BeforeEach
public void initConfig() {
config = new PluginConfigWrapper(
new SharingPluginConfig("TestPlugin", new Action[] { new Action("someId", "someImportURL",
"someActionName", "metadata.type.externalName=='programming exercise'") }),
"http://localhost:8080/xxx");
}
@Test
public void testExpressionFiltersOnMetaData() throws JsonParseException, JsonMappingException, IOException {
ActionWrapper actionWrapper = config.getActions().get("someId");
Assert.assertTrue("metaData1 should be applicable",
actionWrapper.isApplicable(readTestResults("metaData1.yaml")));
Assert.assertFalse("metaData2 should not be applicable",
actionWrapper.isApplicable(readTestResults("metaData2.yaml")));
@BeforeAll
public static void setUpESServer() throws IOException, NodeValidationException {
LOGGER.info("Starting es test server");
ElasticSearchTestServerConfiguration.getTestInstance().startTestNode();
LOGGER.info("Started es test server");
}
/**
* temporary static test data.
*
* @param infoString just a string to add to testdata description.
* @return
* @throws IOException
* @throws JsonMappingException
* @throws JsonParseException
*/
private SearchResultDTO readTestResults(String testFile)
throws JsonParseException, JsonMappingException, IOException {
ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
mapper.findAndRegisterModules();
LOGGER.debug("reading test data from {} ", testFile);
final String resourceName = "./testData/" + testFile;
final InputStream resourceStream = this.getClass().getResourceAsStream(resourceName);
Assert.assertNotNull("cannot find resource at " + resourceName, resourceStream);
byte[] fileContent = FileCopyUtils.copyToByteArray(resourceStream);
UserProvidedMetadataDTO metaData = mapper.readValue(fileContent, UserProvidedMetadataDTO.class);
SearchResultDTO result = new SearchResultDTO();
result.setMetadata(metaData);
return result;
}
@Test
public void testFullTextSearch() throws Exception {
LOGGER.info("starting testFullTextSearch");
......
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