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
8d00e984
Verified
Commit
8d00e984
authored
Jan 09, 2021
by
Lukas Wiest
🚂
Browse files
refactor(model): rename result classes to not hold product name
parent
321f22be
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/hftstuttgart/models/
Modocot
Result.java
→
src/main/java/de/hftstuttgart/models/Result.java
View file @
8d00e984
package
de.hftstuttgart.models
;
public
class
Modocot
Result
public
class
Result
{
public
String
name
;
public
int
state
;
...
...
src/main/java/de/hftstuttgart/models/
Modocot
ResultSummary.java
→
src/main/java/de/hftstuttgart/models/ResultSummary.java
View file @
8d00e984
...
...
@@ -3,9 +3,9 @@ package de.hftstuttgart.models;
import
java.util.HashSet
;
import
java.util.Set
;
public
class
Modocot
ResultSummary
public
class
ResultSummary
{
public
long
timestamp
=
System
.
currentTimeMillis
()
/
1000
;
public
String
globalStacktrace
=
null
;
public
Set
<
Modocot
Result
>
results
=
new
HashSet
<>();
public
Set
<
Result
>
results
=
new
HashSet
<>();
}
src/main/java/de/hftstuttgart/rest/v1/task/TaskUpload.java
View file @
8d00e984
package
de.hftstuttgart.rest.v1.task
;
import
de.hftstuttgart.models.
Modocot
ResultSummary
;
import
de.hftstuttgart.models.ResultSummary
;
import
de.hftstuttgart.utils.*
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
...
...
@@ -45,8 +45,8 @@ public class TaskUpload {
}
@RequestMapping
(
method
=
RequestMethod
.
POST
)
public
Modocot
ResultSummary
uploadAndTestFile
(
@RequestParam
(
"taskFile"
)
MultipartFile
taskFileRef
,
@RequestParam
(
"assignmentId"
)
String
assignmentId
public
ResultSummary
uploadAndTestFile
(
@RequestParam
(
"taskFile"
)
MultipartFile
taskFileRef
,
@RequestParam
(
"assignmentId"
)
String
assignmentId
)
throws
IOException
,
InterruptedException
{
LOG
.
info
(
"submission for testing received"
);
...
...
@@ -81,7 +81,7 @@ public class TaskUpload {
// run test
LOG
.
debug
(
"calling test execution"
);
Modocot
ResultSummary
resultSummary
=
executeTestUtil
.
runTests
(
assignmentId
,
workDirectory
);
ResultSummary
resultSummary
=
executeTestUtil
.
runTests
(
assignmentId
,
workDirectory
);
if
(
mimeInfo
.
equals
(
"text/plain"
))
{
LOG
.
info
(
"check for provided Ticketsystem information"
);
...
...
src/main/java/de/hftstuttgart/utils/ExecuteTestUtil.java
View file @
8d00e984
...
...
@@ -3,7 +3,7 @@ package de.hftstuttgart.utils;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.github.dockerjava.api.model.Bind
;
import
com.github.dockerjava.api.model.Volume
;
import
de.hftstuttgart.models.
Modocot
ResultSummary
;
import
de.hftstuttgart.models.ResultSummary
;
import
org.apache.log4j.LogManager
;
import
org.apache.log4j.Logger
;
import
org.springframework.core.env.Environment
;
...
...
@@ -44,7 +44,7 @@ public class ExecuteTestUtil {
this
.
testTmpPathModocot
=
Paths
.
get
(
env
.
getProperty
(
"modocot.tests.tmp.dir"
));
}
public
Modocot
ResultSummary
runTests
(
String
assignmentId
,
Path
workDirectory
)
throws
IOException
,
InterruptedException
{
public
ResultSummary
runTests
(
String
assignmentId
,
Path
workDirectory
)
throws
IOException
,
InterruptedException
{
// define paths for the test, the submission and where the result is to be expected afterwards
Path
testPath
=
Paths
.
get
(
workDirectory
.
toAbsolutePath
().
toString
(),
"test"
);
...
...
@@ -115,9 +115,9 @@ public class ExecuteTestUtil {
LOG
.
debug
(
"parse results json"
);
ObjectMapper
objectMapper
=
new
ObjectMapper
();
Modocot
ResultSummary
resultSummary
=
objectMapper
.
readValue
(
ResultSummary
resultSummary
=
objectMapper
.
readValue
(
resultFile
.
toURI
().
toURL
(),
Modocot
ResultSummary
.
class
);
ResultSummary
.
class
);
return
resultSummary
;
}
...
...
src/main/java/de/hftstuttgart/utils/UnifiedTicketingUtil.java
View file @
8d00e984
package
de.hftstuttgart.utils
;
import
de.hftstuttgart.models.
Modocot
Result
;
import
de.hftstuttgart.models.
Modocot
ResultSummary
;
import
de.hftstuttgart.models.Result
;
import
de.hftstuttgart.models.ResultSummary
;
import
de.hftstuttgart.unifiedticketing.core.Filter
;
import
de.hftstuttgart.unifiedticketing.core.Ticket
;
import
de.hftstuttgart.unifiedticketing.core.TicketBuilder
;
...
...
@@ -29,7 +29,7 @@ public class UnifiedTicketingUtil {
private
final
static
String
MODOCOT_LABEL
=
"MoDoCoT created"
;
private
final
static
String
MODOCOT_TITLE
=
" | "
+
MODOCOT_LABEL
;
public
static
String
createTicketDescriptionFromResult
(
TicketSystem
ts
,
Modocot
Result
result
,
boolean
compilationError
)
{
public
static
String
createTicketDescriptionFromResult
(
TicketSystem
ts
,
Result
result
,
boolean
compilationError
)
{
StringBuilder
sb
=
new
StringBuilder
();
// heading
...
...
@@ -73,7 +73,7 @@ public class UnifiedTicketingUtil {
return
sb
.
toString
();
}
public
static
String
createTicketTitleFromResult
(
TicketSystem
ts
,
Modocot
Result
result
,
boolean
compilationError
)
{
public
static
String
createTicketTitleFromResult
(
TicketSystem
ts
,
Result
result
,
boolean
compilationError
)
{
StringBuilder
sb
=
new
StringBuilder
();
String
separator
=
" | "
;
...
...
@@ -97,7 +97,7 @@ public class UnifiedTicketingUtil {
return
sb
.
toString
();
}
public
static
Ticket
createTicketFromResult
(
TicketSystem
ts
,
Modocot
Result
result
,
boolean
compilationError
)
{
public
static
Ticket
createTicketFromResult
(
TicketSystem
ts
,
Result
result
,
boolean
compilationError
)
{
TicketBuilder
tb
=
ts
.
createTicket
()
.
title
(
createTicketTitleFromResult
(
ts
,
result
,
compilationError
))
.
description
(
createTicketDescriptionFromResult
(
ts
,
result
,
compilationError
));
...
...
@@ -142,7 +142,7 @@ public class UnifiedTicketingUtil {
return
ret
;
}
public
static
String
getHashForFailure
(
Modocot
Result
result
)
{
public
static
String
getHashForFailure
(
Result
result
)
{
MessageDigest
digest
;
try
{
...
...
@@ -166,7 +166,7 @@ public class UnifiedTicketingUtil {
return
hexString
.
substring
(
hexString
.
length
()
-
9
,
hexString
.
length
()
-
1
);
}
public
static
void
processResult
(
TicketSystem
ts
,
Set
<
Ticket
>
tickets
,
Modocot
Result
result
,
boolean
compilationError
)
{
public
static
void
processResult
(
TicketSystem
ts
,
Set
<
Ticket
>
tickets
,
Result
result
,
boolean
compilationError
)
{
LOG
.
debug
(
String
.
format
(
"retrieving hash for %s"
,
result
.
name
));
String
hash
=
getHashForFailure
(
result
);
...
...
@@ -195,7 +195,7 @@ public class UnifiedTicketingUtil {
* @param meta student uploaded file
* @param resultSummary summary from the testrunner container
*/
public
static
void
reportResults
(
InputStream
meta
,
Modocot
ResultSummary
resultSummary
)
{
public
static
void
reportResults
(
InputStream
meta
,
ResultSummary
resultSummary
)
{
try
{
reportResults
(
meta
,
resultSummary
,
false
);
}
catch
(
InterruptedException
e
)
{
...
...
@@ -212,7 +212,7 @@ public class UnifiedTicketingUtil {
* @param wait if we should block until the ticket creation has finished
* @throws InterruptedException
*/
public
static
void
reportResults
(
InputStream
meta
,
Modocot
ResultSummary
resultSummary
,
boolean
wait
)
throws
InterruptedException
{
public
static
void
reportResults
(
InputStream
meta
,
ResultSummary
resultSummary
,
boolean
wait
)
throws
InterruptedException
{
LOG
.
debug
(
"preparing thread for ticket result submitting"
);
Thread
unifiedTicketingUtil
=
new
Thread
(()
->
{
...
...
@@ -257,7 +257,7 @@ public class UnifiedTicketingUtil {
}
}
public
static
void
reportToTicketsystem
(
TicketSystem
ts
,
Modocot
ResultSummary
resultSummary
)
{
public
static
void
reportToTicketsystem
(
TicketSystem
ts
,
ResultSummary
resultSummary
)
{
// tickets existing yet
LOG
.
debug
(
"fetching existing tickets"
);
Set
<
Ticket
>
tickets
=
fetchExistingModocotTickets
(
ts
);
...
...
@@ -265,18 +265,18 @@ public class UnifiedTicketingUtil {
// for each fail or compile error
LOG
.
debug
(
"start failed tests reporting"
);
resultSummary
.
results
.
stream
()
.
filter
(
r
->
r
.
state
==
Modocot
Result
.
State
.
FAILURE
.
ordinal
())
.
filter
(
r
->
r
.
state
==
Result
.
State
.
FAILURE
.
ordinal
())
.
forEach
(
f
->
processResult
(
ts
,
tickets
,
f
,
false
));
LOG
.
debug
(
"start compilation errors reporting"
);
resultSummary
.
results
.
stream
()
.
filter
(
r
->
r
.
state
==
Modocot
Result
.
State
.
COMPILATIONERROR
.
ordinal
())
.
filter
(
r
->
r
.
state
==
Result
.
State
.
COMPILATIONERROR
.
ordinal
())
.
forEach
(
c
->
processResult
(
ts
,
tickets
,
c
,
true
));
LOG
.
debug
(
"closing all remaining tickets, no longer appeared"
);
tickets
.
forEach
(
ticket
->
ticket
.
close
().
save
());
}
public
static
Ticket
updateTicketFromResult
(
TicketSystem
ts
,
Ticket
ticket
,
Modocot
Result
result
,
boolean
compilationError
)
{
public
static
Ticket
updateTicketFromResult
(
TicketSystem
ts
,
Ticket
ticket
,
Result
result
,
boolean
compilationError
)
{
ticket
.
open
()
.
setTitle
(
createTicketTitleFromResult
(
ts
,
result
,
compilationError
))
...
...
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