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
cbd7206a
Commit
cbd7206a
authored
3 years ago
by
Eduard Frankford
Browse files
Options
Downloads
Patches
Plain Diff
improved tests
parent
0fd86673
Branches
Branches containing commit
2 merge requests
!91
Bringing JHipster7.6.0 to production
,
!75
Improve tests
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.classpath
+6
-3
6 additions, 3 deletions
.classpath
src/test/java/at/ac/uibk/gitsearch/service/ExerciseServiceIT.java
+43
-47
43 additions, 47 deletions
.../java/at/ac/uibk/gitsearch/service/ExerciseServiceIT.java
with
49 additions
and
50 deletions
.classpath
+
6
−
3
View file @
cbd7206a
...
...
@@ -34,14 +34,17 @@
<attribute
name=
"maven.pomderived"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
path=
"target/generated-sources/annotations"
>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"target/generated-
test-
sources/
test-
annotations"
>
<attributes>
<attribute
name=
"test"
value=
"true"
/>
<attribute
name=
"optional"
value=
"true"
/>
<attribute
name=
"maven.pomderived"
value=
"true"
/>
<attribute
name=
"ignore_optional_problems"
value=
"true"
/>
<attribute
name=
"m2e-apt"
value=
"true"
/>
</attributes>
</classpathentry>
<classpathentry
kind=
"src"
output=
"target/test-classes"
path=
"target/generated-
test-
sources/
test-
annotations"
>
<classpathentry
kind=
"src"
path=
"target/generated-sources/annotations"
>
<attributes>
<attribute
name=
"test"
value=
"true"
/>
<attribute
name=
"optional"
value=
"true"
/>
</attributes>
</classpathentry>
...
...
This diff is collapsed.
Click to expand it.
src/test/java/at/ac/uibk/gitsearch/service/ExerciseServiceIT.java
+
43
−
47
View file @
cbd7206a
package
at.ac.uibk.gitsearch.service
;
import
at.ac.uibk.gitsearch.GitsearchApp
;
import
at.ac.uibk.gitsearch.es.model.ArtemisExerciseInfo
;
import
at.ac.uibk.gitsearch.es.model.ExerciseInfo
;
import
at.ac.uibk.gitsearch.repository.search.testESService.ElasticSearchTestServerConfiguration
;
import
static
at
.
ac
.
uibk
.
gitsearch
.
web
.
rest
.
AccountResourceIT
.
TEST_USER_LOGIN
;
import
static
org
.
mockito
.
Mockito
.
doNothing
;
import
static
org
.
mockito
.
Mockito
.
doReturn
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.apache.commons.io.FileUtils
;
import
org.eclipse.jgit.api.Git
;
import
org.eclipse.jgit.attributes.AttributesNodeProvider
;
import
org.eclipse.jgit.lib.*
;
import
org.eclipse.jgit.lib.Repository
;
import
org.eclipse.jgit.storage.file.FileRepositoryBuilder
;
import
org.elasticsearch.node.NodeValidationException
;
import
org.gitlab4j.api.models.Group
;
import
org.junit.After
;
import
org.junit.Assert
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.runner.RunWith
;
import
org.mockito.*
;
import
org.mockito.InjectMocks
;
import
org.mockito.MockitoAnnotations
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.mock.mockito.MockBean
;
import
org.springframework.security.test.context.support.WithMockUser
;
import
org.springframework.test.context.TestPropertySource
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.ws.rs.client.Client
;
import
javax.ws.rs.client.ClientBuilder
;
import
javax.ws.rs.client.Invocation
;
import
javax.ws.rs.client.WebTarget
;
import
java.io.*
;
import
java.nio.file.Files
;
import
static
at
.
ac
.
uibk
.
gitsearch
.
web
.
rest
.
AccountResourceIT
.
TEST_USER_LOGIN
;
import
static
org
.
mockito
.
Mockito
.*;
import
at.ac.uibk.gitsearch.GitsearchApp
;
import
at.ac.uibk.gitsearch.es.model.ArtemisExerciseInfo
;
@SpringBootTest
(
classes
=
GitsearchApp
.
class
)
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
...
...
@@ -78,7 +75,6 @@ public class ExerciseServiceIT {
Group
group
=
new
Group
();
Repository
jgitRepo
=
FileRepositoryBuilder
.
create
(
new
File
(
"tmp-import/"
+
token
,
".git"
));
// mocks
doNothing
().
when
(
gitlabService
).
setJGitDefaultAuth
();
doReturn
(
group
).
when
(
gitlabService
).
getGroupById
(
gitlabGroup
);
...
...
@@ -86,7 +82,6 @@ public class ExerciseServiceIT {
doReturn
(
jgitRepo
).
when
(
gitlabService
).
checkoutRepo
(
"repoUrl"
);
doNothing
().
when
(
gitlabService
).
commitAndPushToRepo
(
jgitRepo
,
new
File
(
"tmp-import"
,
token
));
exerciseService
.
importExercise
(
artemisExerciseInfo
,
token
,
gitlabGroup
);
// asserts
...
...
@@ -102,10 +97,9 @@ public class ExerciseServiceIT {
exerciseService
.
applyExerciseInfoChanges
(
artemisExerciseInfo
,
token
);
Assert
.
assertEquals
(
"metadataVersion: \"1\"\n"
+
"title: \"TestTitle\"\n"
+
"license: \"testLicense\"\n"
+
"learningResourceType: \"Artemis\""
,
new
String
(
Files
.
readAllBytes
(
metadata
.
toPath
())).
strip
());
Assert
.
assertEquals
(
"learningResourceType: \"Artemis\"\n"
+
"license: \"testLicense\"\n"
+
"metadataVersion: \"1\"\n"
+
"title: \"TestTitle\""
,
new
String
(
Files
.
readAllBytes
(
metadata
.
toPath
())).
strip
());
}
@Test
...
...
@@ -114,20 +108,11 @@ public class ExerciseServiceIT {
metadata
.
getParentFile
().
mkdirs
();
metadata
.
createNewFile
();
FileWriter
writer
=
new
FileWriter
(
metadata
);
writer
.
write
(
"{\n"
+
" \"metadataVersion\": \"1\",\n"
+
" \"type\": \"programming exercise\",\n"
+
" \"title\": \"TestTitle\",\n"
+
" \"license\": \"testLicense\",\n"
+
" \"maxPoints\": 100,\n"
+
" \"bonusPoints\": 100,\n"
+
" \"mode\": \"INDIVIDUAL\",\n"
+
" \"staticCodeAnalysis\": false,\n"
+
" \"allowOfflineIDE\": false,\n"
+
" \"allowOnlineEditor\": false,\n"
+
" \"showTestNamesToStudents\": false,\n"
+
" \"sequentialTestRuns\": false\n"
+
"}"
);
writer
.
write
(
"{\n"
+
" \"metadataVersion\": \"1\",\n"
+
" \"type\": \"programming exercise\",\n"
+
" \"title\": \"TestTitle\",\n"
+
" \"license\": \"testLicense\",\n"
+
" \"maxPoints\": 100,\n"
+
" \"bonusPoints\": 100,\n"
+
" \"mode\": \"INDIVIDUAL\",\n"
+
" \"staticCodeAnalysis\": false,\n"
+
" \"allowOfflineIDE\": false,\n"
+
" \"allowOnlineEditor\": false,\n"
+
" \"showTestNamesToStudents\": false,\n"
+
" \"sequentialTestRuns\": false\n"
+
"}"
);
writer
.
close
();
artemisExerciseInfo
.
setMaxPoints
(
100
f
);
...
...
@@ -138,6 +123,13 @@ public class ExerciseServiceIT {
artemisExerciseInfo
.
setAllowOnlineEditor
(
false
);
artemisExerciseInfo
.
setShowTestNamesToStudents
(
false
);
artemisExerciseInfo
.
setSequentialTestRuns
(
false
);
artemisExerciseInfo
.
setLearningResourceType
(
null
);
artemisExerciseInfo
.
setStructure
(
"atomic"
);
List
<
String
>
str
=
new
ArrayList
<>();
str
.
add
(
"artemis"
);
artemisExerciseInfo
.
setFormat
(
str
);
Assert
.
assertEquals
(
artemisExerciseInfo
,
exerciseService
.
getArtemisExerciseInfo
(
token
));
}
...
...
@@ -148,14 +140,18 @@ public class ExerciseServiceIT {
metadata
.
getParentFile
().
mkdirs
();
metadata
.
createNewFile
();
FileWriter
writer
=
new
FileWriter
(
metadata
);
writer
.
write
(
"{\n"
+
" \"metadataVersion\": \"1\",\n"
+
" \"type\": \"programming exercise\",\n"
+
" \"title\": \"TestTitle\",\n"
+
" \"license\": \"testLicense\"\n"
+
"}"
);
writer
.
write
(
"{\n"
+
" \"metadataVersion\": \"1\",\n"
+
" \"type\": \"programming exercise\",\n"
+
" \"title\": \"TestTitle\",\n"
+
" \"license\": \"testLicense\"\n"
+
"}"
);
writer
.
close
();
artemisExerciseInfo
.
setLearningResourceType
(
null
);
artemisExerciseInfo
.
setStructure
(
"atomic"
);
List
<
String
>
str
=
new
ArrayList
<>();
str
.
add
(
"artemis"
);
artemisExerciseInfo
.
setFormat
(
str
);
Assert
.
assertEquals
(
artemisExerciseInfo
,
exerciseService
.
getArtemisExerciseInfo
(
token
));
}
...
...
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