Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Dockerized Testing Toolkit
DTT Backend
Commits
a54d91a6
Verified
Commit
a54d91a6
authored
Jan 09, 2021
by
Lukas Wiest
🚂
Browse files
refactor(taskupload): ditch json conversion to legacy format
parent
078a7ac2
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/hftstuttgart/models/LegacyMoodleResult.java
deleted
100644 → 0
View file @
078a7ac2
package
de.hftstuttgart.models
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
class
LegacyMoodleResult
{
public
List
<
LegacyMoodleTestResult
>
testResults
;
public
List
<
LegacyMoodleCompilationError
>
compilationErrors
;
public
static
LegacyMoodleResult
convertToModdleResult
(
ModocotResultSummary
summary
)
{
LegacyMoodleTestResult
tests
=
new
LegacyMoodleTestResult
();
tests
.
failureCount
=
summary
.
failureCount
;
tests
.
testCount
=
summary
.
testCount
;
tests
.
successfulTests
=
summary
.
successes
.
stream
()
.
map
(
s
->
s
.
name
)
.
collect
(
Collectors
.
toList
());
tests
.
testFailures
=
summary
.
failures
.
stream
()
.
map
(
f
->
{
LegacyMoodleTestFailure
failure
=
new
LegacyMoodleTestFailure
();
failure
.
testHeader
=
f
.
name
;
failure
.
message
=
f
.
failureReason
;
failure
.
trace
=
f
.
stacktrace
;
return
failure
;
})
.
collect
(
Collectors
.
toList
());
List
<
LegacyMoodleCompilationError
>
compilationErrors
;
compilationErrors
=
summary
.
compilationErrors
.
stream
()
.
map
(
f
->
{
LegacyMoodleCompilationError
cError
=
new
LegacyMoodleCompilationError
();
cError
.
javaFileName
=
f
.
name
;
cError
.
message
=
f
.
failureReason
;
cError
.
lineNumber
=
f
.
lineNumber
;
cError
.
columnNumber
=
f
.
columnNumber
;
cError
.
position
=
f
.
position
;
return
cError
;
})
.
collect
(
Collectors
.
toList
());
LegacyMoodleResult
result
=
new
LegacyMoodleResult
();
result
.
testResults
=
Collections
.
singletonList
(
tests
);
result
.
compilationErrors
=
compilationErrors
;
return
result
;
}
private
static
class
LegacyMoodleTestResult
{
public
String
testName
=
"UnitTests"
;
public
int
testCount
;
public
int
failureCount
;
public
List
<
String
>
successfulTests
;
public
List
<
LegacyMoodleTestFailure
>
testFailures
;
}
private
static
class
LegacyMoodleTestFailure
{
public
String
testHeader
;
public
String
message
;
public
String
trace
;
}
private
static
class
LegacyMoodleCompilationError
{
public
String
message
;
public
String
javaFileName
;
public
int
lineNumber
;
public
int
columnNumber
;
public
int
position
;
}
}
src/main/java/de/hftstuttgart/rest/v1/task/TaskUpload.java
View file @
a54d91a6
package
de.hftstuttgart.rest.v1.task
;
import
de.hftstuttgart.models.LegacyMoodleResult
;
import
de.hftstuttgart.models.ModocotResultSummary
;
import
de.hftstuttgart.utils.*
;
import
org.apache.logging.log4j.LogManager
;
...
...
@@ -46,7 +45,7 @@ public class TaskUpload {
}
@RequestMapping
(
method
=
RequestMethod
.
POST
)
public
LegacyMoodleResult
uploadAndTestFile
(
@RequestParam
(
"taskFile"
)
MultipartFile
taskFileRef
,
public
ModocotResultSummary
uploadAndTestFile
(
@RequestParam
(
"taskFile"
)
MultipartFile
taskFileRef
,
@RequestParam
(
"assignmentId"
)
String
assignmentId
)
throws
IOException
,
InterruptedException
{
LOG
.
info
(
"submission for testing received"
);
...
...
@@ -84,16 +83,12 @@ public class TaskUpload {
LOG
.
debug
(
"calling test execution"
);
ModocotResultSummary
resultSummary
=
executeTestUtil
.
runTests
(
assignmentId
,
workDirectory
);
// convert to moddle plugin readable format and return to moodle
LOG
.
debug
(
"convert to moodle understandable format"
);
LegacyMoodleResult
moodleResult
=
LegacyMoodleResult
.
convertToModdleResult
(
resultSummary
);
if
(
mimeInfo
.
equals
(
"text/plain"
))
{
LOG
.
info
(
"check for provided Ticketsystem information"
);
UnifiedTicketingUtil
.
reportResults
(
taskFileRef
.
getInputStream
(),
resultSummary
);
}
LOG
.
info
(
"submission tested successfully"
);
return
moodleResult
;
return
resultSummary
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment