Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PDA Testing Tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
winfo
code-pro
PDA Testing Framework
PDA Testing Tool
Commits
d8b59888
Commit
d8b59888
authored
3 years ago
by
Henning Josef Moritz Werner Schmeink
Browse files
Options
Downloads
Patches
Plain Diff
Updated ChangeController, now it calls the right PrioritizationService
parent
20d2f028
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/change/ChangeController.java
+216
-225
216 additions, 225 deletions
...s/Testgenerator/rest/service/change/ChangeController.java
with
216 additions
and
225 deletions
Testgenerator/src/main/java/de/fhmuenster/masterthesis/Testgenerator/rest/service/change/ChangeController.java
+
216
−
225
View file @
d8b59888
package
de.fhmuenster.masterthesis.Testgenerator.rest.service.change
;
package
de.fhmuenster.masterthesis.Testgenerator.rest.service.change
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardCopyOption
;
import
java.nio.file.StandardCopyOption
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.List
;
import
org.eclipse.emf.common.util.BasicEList
;
import
org.eclipse.emf.common.util.BasicEList
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNTestcase
;
import
de.fhmuenster.masterthesis.Testgenerator.bpmn.data.BPMNTestcase
;
import
de.fhmuenster.masterthesis.Testgenerator.bpmn.data.TaskVariables
;
import
de.fhmuenster.masterthesis.Testgenerator.bpmn.data.TaskVariables
;
import
de.fhmuenster.masterthesis.Testgenerator.bpmn.data.VariableValue
;
import
de.fhmuenster.masterthesis.Testgenerator.bpmn.data.VariableValue
;
import
de.fhmuenster.masterthesis.Testgenerator.migration.MigrationResultWrapper
;
import
de.fhmuenster.masterthesis.Testgenerator.migration.MigrationResultWrapper
;
import
de.fhmuenster.masterthesis.Testgenerator.migration.MigrationService
;
import
de.fhmuenster.masterthesis.Testgenerator.migration.MigrationService
;
import
de.fhmuenster.masterthesis.Testgenerator.prioritization.PrioritizationService
;
import
de.fhmuenster.masterthesis.Testgenerator.prioritization.PrioritizationService
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.dto.MigrationResultWrapperDTO
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.dto.MigrationResultWrapperDTO
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.mapper.ObjectMapper
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.mapper.ObjectMapper
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.converters.TestConverter
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.converters.TestConverter
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.flow.FlowService
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.flow.FlowService
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.project.Project
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.project.Project
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.project.ProjectService
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.project.ProjectService
;
import
de.fhmuenster.masterthesis.Testgenerator.utils.ProjectDirectoryUtils
;
import
de.fhmuenster.masterthesis.Testgenerator.utils.ProjectDirectoryUtils
;
import
de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer
;
import
de.fhmuenster.masterthesis.serialization.TestgeneratorDSLSerializer
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.test.TestService
;
import
de.fhmuenster.masterthesis.Testgenerator.rest.service.test.TestService
;
import
de.fhmuenster.masterthesis.testgeneratorDSL.Flow
;
import
de.fhmuenster.masterthesis.testgeneratorDSL.Flow
;
import
de.fhmuenster.masterthesis.testgeneratorDSL.Test
;
import
de.fhmuenster.masterthesis.testgeneratorDSL.Test
;
import
de.fhmuenster.masterthesis.testgeneratorDSL.UserTaskFlowElement
;
import
de.fhmuenster.masterthesis.testgeneratorDSL.UserTaskFlowElement
;
import
de.fhmuenster.masterthesis.testgeneratorDSL.VariableReference
;
import
de.fhmuenster.masterthesis.testgeneratorDSL.VariableReference
;
@RestController
@RestController
public
class
ChangeController
{
public
class
ChangeController
{
private
static
final
ObjectMapper
MAPPER_FLOW
=
new
ObjectMapper
()
private
static
final
ObjectMapper
MAPPER_FLOW
=
new
ObjectMapper
()
.
withFlowConverter
();
.
withFlowConverter
();
@Autowired
@Autowired
private
ProjectService
projectService
;
private
ProjectService
projectService
;
@Autowired
@Autowired
private
FlowService
flowService
;
private
FlowService
flowService
;
@Autowired
@Autowired
private
ChangeService
changeService
;
private
ChangeService
changeService
;
@Autowired
@Autowired
private
MigrationService
migrationService
;
private
MigrationService
migrationService
;
@Autowired
@Autowired
private
TestService
testService
;
private
TestService
testService
;
@RequestMapping
(
path
=
"/project/{projectId}/match"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/project/{projectId}/match"
,
method
=
RequestMethod
.
GET
)
public
void
getNewFlows
(
@PathVariable
(
required
=
true
)
Long
projectId
)
{
public
void
getNewFlows
(
@PathVariable
(
required
=
true
)
Long
projectId
)
{
Project
projectForId
=
projectService
.
getProjectForId
(
projectId
);
Project
projectForId
=
projectService
.
getProjectForId
(
projectId
);
//speichern aller neuen Flows
//speichern aller neuen Flows
List
<
Flow
>
newFlows
=
flowService
.
getFlows
(
projectForId
.
getProjectDirectories
());
List
<
Flow
>
newFlows
=
flowService
.
getFlows
(
projectForId
.
getProjectDirectories
());
// System.out.println("new: " +newFlowsElements);
// System.out.println("new: " +newFlowsElements);
// System.out.println("old flow --------------------------------------------");
// System.out.println("old flow --------------------------------------------");
//für alte Flows
//für alte Flows
String
pathOld
=
"D:\\VSProjects\\fe-pda-testing-tool\\OnlineSchuhDemo\\dsl_matching\\MatchingTestcollectionOld.bpmn-testgen"
;
String
pathOld
=
"D:\\VSProjects\\fe-pda-testing-tool\\OnlineSchuhDemo\\dsl_matching\\MatchingTestcollectionOld.bpmn-testgen"
;
List
<
Flow
>
oldFlows
=
flowService
.
getOldFlows
(
pathOld
);
List
<
Flow
>
oldFlows
=
flowService
.
getOldFlows
(
pathOld
);
Flow
[][]
matchingFlows
=
changeService
.
compareFlows
(
newFlows
,
oldFlows
);
Flow
[][]
matchingFlows
=
changeService
.
compareFlows
(
newFlows
,
oldFlows
);
// for (int i=0; i<newFlows.size();i++) {
// for (int i=0; i<newFlows.size();i++) {
// System.out.println(matchingFlows[i][0]+" "+matchingFlows[i][1]);
// System.out.println(matchingFlows[i][0]+" "+matchingFlows[i][1]);
//
//
// }
// }
}
}
@RequestMapping
(
path
=
"/project/{projectId}/migration/changes"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/project/{projectId}/migration/changes"
,
method
=
RequestMethod
.
GET
)
public
MigrationResultWrapperDTO
detectChanges
(
@PathVariable
(
required
=
true
)
Long
projectId
)
{
public
MigrationResultWrapperDTO
detectChanges
(
@PathVariable
(
required
=
true
)
Long
projectId
)
{
//Annahme: Flows stimmen überein
//Annahme: Flows stimmen überein
Project
project
=
projectService
.
getProjectForId
(
projectId
);
Project
project
=
projectService
.
getProjectForId
(
projectId
);
MigrationResultWrapperDTO
migrationResultWrapperDTO
=
new
MigrationResultWrapperDTO
();
MigrationResultWrapperDTO
migrationResultWrapperDTO
=
new
MigrationResultWrapperDTO
();
//Alte DSL kopieren und neu generieren
//Alte DSL kopieren und neu generieren
Path
testFilePath
=
ProjectDirectoryUtils
.
getTestspecificationPath
(
project
.
getProjectDirectories
());
Path
testFilePath
=
ProjectDirectoryUtils
.
getTestspecificationPath
(
project
.
getProjectDirectories
());
Path
source
=
Paths
.
get
(
testFilePath
.
toString
());
Path
source
=
Paths
.
get
(
testFilePath
.
toString
());
Path
target
=
Paths
.
get
(
project
.
getProjectDirectories
().
getProjectRootPath
().
toString
(),
Path
target
=
Paths
.
get
(
project
.
getProjectDirectories
().
getProjectRootPath
().
toString
(),
project
.
getProjectDirectories
().
getModelPath
(),
this
.
projectService
.
getBackupFolderName
(),
project
.
getProjectDirectories
().
getModelPath
(),
this
.
projectService
.
getBackupFolderName
(),
"Testcollection.bpmn-testgen"
);
"Testcollection.bpmn-testgen"
);
try
{
try
{
Files
.
move
(
source
,
target
,
StandardCopyOption
.
REPLACE_EXISTING
);
Files
.
move
(
source
,
target
,
StandardCopyOption
.
REPLACE_EXISTING
);
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
)
{
}
}
//Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories());
//Path testFilePath = ProjectDirectoryUtils.getTestspecificationPath(project.getProjectDirectories());
Path
newDSLFile
=
Paths
.
get
(
testFilePath
.
toString
());
Path
newDSLFile
=
Paths
.
get
(
testFilePath
.
toString
());
//Path oldDSLFile = Paths.get(project.getProjectDirectories().resolveTestPath(), "Testcollection-old.bpmn-testgen");
//Path oldDSLFile = Paths.get(project.getProjectDirectories().resolveTestPath(), "Testcollection-old.bpmn-testgen");
Path
oldDSLFile
=
Paths
.
get
(
project
.
getProjectDirectories
().
getProjectRootPath
().
toString
(),
Path
oldDSLFile
=
Paths
.
get
(
project
.
getProjectDirectories
().
getProjectRootPath
().
toString
(),
project
.
getProjectDirectories
().
getModelPath
(),
this
.
projectService
.
getBackupFolderName
(),
project
.
getProjectDirectories
().
getModelPath
(),
this
.
projectService
.
getBackupFolderName
(),
"Testcollection.bpmn-testgen"
);
"Testcollection.bpmn-testgen"
);
testService
.
initLoops
(
project
);
testService
.
initLoops
(
project
);
testService
.
initTestcollection
(
project
);
testService
.
initTestcollection
(
project
);
try
{
try
{
TestgeneratorDSLSerializer
oldDSL
=
new
TestgeneratorDSLSerializer
(
oldDSLFile
.
toString
());
TestgeneratorDSLSerializer
oldDSL
=
new
TestgeneratorDSLSerializer
(
oldDSLFile
.
toString
());
TestgeneratorDSLSerializer
newDSL
=
new
TestgeneratorDSLSerializer
(
newDSLFile
.
toString
());
TestgeneratorDSLSerializer
newDSL
=
new
TestgeneratorDSLSerializer
(
newDSLFile
.
toString
());
/*
/*
* Prioritäten der Tests der neuen DSL hinzufügen
* Prioritäten der Tests der neuen DSL hinzufügen
* Hinzufügen der Tests über den @testService.addTest(..)
* Hinzufügen der Tests über den @testService.addTest(..)
*/
*/
List
<
Flow
>
flows
=
oldDSL
.
getFlows
();
List
<
Flow
>
flows
=
oldDSL
.
getFlows
();
for
(
Flow
flow
:
flows
)
for
(
Flow
flow
:
flows
)
{
{
List
<
Test
>
oldTests
=
oldDSL
.
getTestsForFlow
(
flow
);
List
<
Test
>
oldTests
=
oldDSL
.
getTestsForFlow
(
flow
);
for
(
Test
test
:
oldTests
)
{
for
(
Test
test
:
oldTests
)
{
BPMNTestcase
bpmnTestcase
=
TestConverter
.
getBPMNTestcase
(
test
);
BPMNTestcase
bpmnTestcase
=
TestConverter
.
getBPMNTestcase
(
test
);
//Prüfen, ob ggf Tasks gelöscht wurden
//Prüfen, ob ggf Tasks gelöscht wurden
List
<
TaskVariables
>
variableListToSet
=
new
ArrayList
<>();
List
<
TaskVariables
>
variableListToSet
=
new
ArrayList
<>();
for
(
TaskVariables
tv
:
bpmnTestcase
.
getTaskVariableList
())
{
for
(
TaskVariables
tv
:
bpmnTestcase
.
getTaskVariableList
())
{
if
(!
newDSL
.
getFlowElements
(
Arrays
.
asList
(
tv
.
getTask
())).
isEmpty
())
{
if
(!
newDSL
.
getFlowElements
(
Arrays
.
asList
(
tv
.
getTask
())).
isEmpty
())
{
variableListToSet
.
add
(
tv
);
variableListToSet
.
add
(
tv
);
}
}
}
}
bpmnTestcase
.
setTaskVariableList
(
variableListToSet
);
bpmnTestcase
.
setTaskVariableList
(
variableListToSet
);
//Prüfen, ob eine Prozessvariable gelöscht wurde, diese muss dann aus der Testspezifikation raus
//Prüfen, ob eine Prozessvariable gelöscht wurde, diese muss dann aus der Testspezifikation raus
int
index
=
0
;
int
index
=
0
;
for
(
TaskVariables
tv
:
bpmnTestcase
.
getTaskVariableList
())
{
for
(
TaskVariables
tv
:
bpmnTestcase
.
getTaskVariableList
())
{
UserTaskFlowElement
oldUserTask
=
(
UserTaskFlowElement
)
oldDSL
.
getFlowElements
(
Arrays
.
asList
(
tv
.
getTask
())).
get
(
0
);
UserTaskFlowElement
oldUserTask
=
(
UserTaskFlowElement
)
oldDSL
.
getFlowElements
(
Arrays
.
asList
(
tv
.
getTask
())).
get
(
0
);
List
<
VariableReference
>
oldInputVariables
=
oldUserTask
.
getInputVariables
();
List
<
VariableReference
>
oldInputVariables
=
oldUserTask
.
getInputVariables
();
UserTaskFlowElement
newUserTask
=
(
UserTaskFlowElement
)
newDSL
.
getFlowElements
(
Arrays
.
asList
(
tv
.
getTask
())).
get
(
0
);
UserTaskFlowElement
newUserTask
=
(
UserTaskFlowElement
)
newDSL
.
getFlowElements
(
Arrays
.
asList
(
tv
.
getTask
())).
get
(
0
);
List
<
VariableReference
>
newInputVariables
=
newUserTask
.
getInputVariables
();
List
<
VariableReference
>
newInputVariables
=
newUserTask
.
getInputVariables
();
List
<
String
>
deletedInputVariables
=
new
ArrayList
<>();
List
<
String
>
deletedInputVariables
=
new
ArrayList
<>();
for
(
VariableReference
v
:
oldInputVariables
)
{
for
(
VariableReference
v
:
oldInputVariables
)
{
if
(
this
.
migrationService
.
checkIfVariableIsDeleted
(
newInputVariables
,
v
))
{
if
(
this
.
migrationService
.
checkIfVariableIsDeleted
(
newInputVariables
,
v
))
{
//System.out.println("Variable " + v.getRef().getName() + " wurd gelöscht");
//System.out.println("Variable " + v.getRef().getName() + " wurd gelöscht");
deletedInputVariables
.
add
(
v
.
getRef
().
getName
());
deletedInputVariables
.
add
(
v
.
getRef
().
getName
());
}
}
}
}
List
<
VariableValue
>
variableValuesToSet
=
new
ArrayList
<>();
List
<
VariableValue
>
variableValuesToSet
=
new
ArrayList
<>();
for
(
VariableValue
vv
:
tv
.
getVariableValues
())
{
for
(
VariableValue
vv
:
tv
.
getVariableValues
())
{
if
(!
deletedInputVariables
.
contains
(
vv
.
getVariable
()))
{
if
(!
deletedInputVariables
.
contains
(
vv
.
getVariable
()))
{
variableValuesToSet
.
add
(
vv
);
variableValuesToSet
.
add
(
vv
);
}
}
}
}
bpmnTestcase
.
getTaskVariableList
().
get
(
index
).
setVariableValues
(
variableValuesToSet
);
bpmnTestcase
.
getTaskVariableList
().
get
(
index
).
setVariableValues
(
variableValuesToSet
);
index
++;
index
++;
}
}
testService
.
addTest
(
bpmnTestcase
,
project
.
getProjectDirectories
());
testService
.
addTest
(
bpmnTestcase
,
project
.
getProjectDirectories
());
}
}
}
}
newDSL
=
null
;
newDSL
=
null
;
newDSL
=
new
TestgeneratorDSLSerializer
(
newDSLFile
.
toString
());
newDSL
=
new
TestgeneratorDSLSerializer
(
newDSLFile
.
toString
());
MigrationResultWrapper
migrationResultWrapper
=
migrationService
.
detectChanges
(
oldDSL
,
newDSL
);
MigrationResultWrapper
migrationResultWrapper
=
migrationService
.
detectChanges
(
oldDSL
,
newDSL
);
migrationResultWrapperDTO
=
migrationService
.
convertMigrationResultWrapper
(
migrationResultWrapper
);
migrationResultWrapperDTO
=
migrationService
.
convertMigrationResultWrapper
(
migrationResultWrapper
);
return
migrationResultWrapperDTO
;
return
migrationResultWrapperDTO
;
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
// TODO Auto-generated catch block
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
migrationResultWrapperDTO
;
return
migrationResultWrapperDTO
;
}
}
/**
/**
* Function to map the restcall for the frontend. The function will run the prioritization service
* Function to map the restcall for the frontend. The function will run the prioritization service
* to prioritize the tests
* to prioritize the tests
* @author Tim Flicke, Henning Schmeink
* @author Tim Flicke, Henning Schmeink
* @return ?
* @return ?
*/
*/
@RequestMapping
(
path
=
"/project/{projectId}/prioritization"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/project/{projectId}/prioritization"
,
method
=
RequestMethod
.
GET
)
public
void
prioritization
(
@PathVariable
(
required
=
true
)
Long
projectId
)
{
public
void
prioritization
(
@PathVariable
(
required
=
true
)
Long
projectId
)
{
Project
project
=
projectService
.
getProjectForId
(
projectId
);
Project
project
=
projectService
.
getProjectForId
(
projectId
);
Path
testFilePath
=
ProjectDirectoryUtils
.
getTestspecificationPath
(
project
.
getProjectDirectories
());
Path
testFilePath
=
ProjectDirectoryUtils
.
getTestspecificationPath
(
project
.
getProjectDirectories
());
// DSL-Dateien einlesen
Path
newDSLFile
=
Paths
.
get
(
testFilePath
.
toString
());
Path
newDSLFile
=
Paths
.
get
(
testFilePath
.
toString
());
TestgeneratorDSLSerializer
newDSL
=
new
TestgeneratorDSLSerializer
(
newDSLFile
.
toString
());
Path
oldDSLFile
=
Paths
.
get
(
project
.
getProjectDirectories
().
resolveTestPath
(),
"Testcollection-old.bpmn-testgen"
);
Path
oldDSLFile
=
Paths
.
get
(
project
.
getProjectDirectories
().
resolveTestPath
(),
"Testcollection-old.bpmn-testgen"
);
try
{
TestgeneratorDSLSerializer
oldDSL
=
new
TestgeneratorDSLSerializer
(
oldDSLFile
.
toString
());
// TODO: Anpassen an das Versionierungskonzept
PrioritizationService
prioService
=
new
PrioritizationService
(
oldDSL
,
newDSL
);
TestgeneratorDSLSerializer
oldDSL
=
new
TestgeneratorDSLSerializer
(
oldDSLFile
.
toString
());
prioService
.
prioritize
();
TestgeneratorDSLSerializer
newDSL
=
new
TestgeneratorDSLSerializer
(
newDSLFile
.
toString
());
}
// PrioritizationService erzeugen anhand der alten und neuen DSL
}
PrioritizationService
prioritizationService
=
new
PrioritizationService
(
oldDSL
,
newDSL
);
prioritizationService
.
prioritize
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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