This is the codeAbility Sharing Platform! Learn more about the
codeAbility Sharing Platform
.
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
codeAbility Sharing Platform
Manage
Activity
Members
Labels
Plan
Issues
43
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
development
sharing
codeAbility Sharing Platform
Commits
ac32de7d
Commit
ac32de7d
authored
4 years ago
by
Michael Breu
Browse files
Options
Downloads
Patches
Plain Diff
Further Fixing Tests
parent
42426d07
1 merge request
!17
Initial Merge to Prepare Release 1.0.0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/test/java/at/ac/uibk/gitsearch/service/SearchServiceIT.java
+8
-48
8 additions, 48 deletions
...st/java/at/ac/uibk/gitsearch/service/SearchServiceIT.java
with
8 additions
and
48 deletions
src/test/java/at/ac/uibk/gitsearch/service/SearchServiceIT.java
+
8
−
48
View file @
ac32de7d
...
...
@@ -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"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment