Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TOP IDE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
TDL Open Source
TOP IDE
Commits
6e400989
Commit
6e400989
authored
9 months ago
by
Philip Makedonski
Browse files
Options
Downloads
Patches
Plain Diff
+generate behaviour first steps
parent
a4864e61
No related branches found
Branches containing commit
Tags
20240708.18.28
Tags containing commit
No related merge requests found
Pipeline
#7122
passed
9 months ago
Stage: build
Stage: prepare
Stage: upload
Stage: release
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/org.etsi.mts.tdl.standalone/src/org/etsi/mts/tdl/standalone/Standalone.java
+118
-17
118 additions, 17 deletions
...tandalone/src/org/etsi/mts/tdl/standalone/Standalone.java
with
118 additions
and
17 deletions
plugins/org.etsi.mts.tdl.standalone/src/org/etsi/mts/tdl/standalone/Standalone.java
+
118
−
17
View file @
6e400989
...
...
@@ -33,8 +33,17 @@ import org.etsi.mts.tdl.ComponentInstanceRole;
import
org.etsi.mts.tdl.Extension
;
import
org.etsi.mts.tdl.GateType
;
import
org.etsi.mts.tdl.Package
;
import
org.etsi.mts.tdl.Behaviour
;
import
org.etsi.mts.tdl.CompoundBehaviour
;
import
org.etsi.mts.tdl.BoundedLoopBehaviour
;
import
org.etsi.mts.tdl.AlternativeBehaviour
;
import
org.etsi.mts.tdl.ConditionalBehaviour
;
import
org.etsi.mts.tdl.ProcedureCall
;
import
org.etsi.mts.tdl.Interaction
;
import
org.etsi.mts.tdl.Message
;
import
org.etsi.mts.tdl.StructuredDataType
;
import
org.etsi.mts.tdl.TestConfiguration
;
import
org.etsi.mts.tdl.TestDescription
;
import
org.etsi.mts.tdl.tdlPackage
;
import
org.etsi.mts.tdl.asn2tdl.ASN2TDLTranslator
;
import
org.etsi.mts.tdl.constraints.evl.Validator
;
...
...
@@ -377,7 +386,33 @@ public class Standalone {
Resource
resource
=
TDLHelper
.
load
(
path
);
//export to external generator
EObject
model
=
resource
.
getContents
().
get
(
0
);
List
<
TestConfiguration
>
testConfigurations
=
EcoreUtil2
.
getAllContentsOfType
(
model
,
TestConfiguration
.
class
);
generateConfiguration
(
path
,
model
);
System
.
out
.
println
();
generateBehaviour
(
path
,
model
);
/*
* @startuml
component Tester {
portout p1c
portout p2c
portout p3c
}
component SUT {
portin p1d
portin p2d
portin p3d
}
p1c <--> p1d
p2c <--> p2d
p3c <--> p3d
@enduml
*/
}
private
void
generateConfiguration
(
String
path
,
EObject
model
)
{
List
<
TestConfiguration
>
testConfigurations
=
EcoreUtil2
.
getAllContentsOfType
(
model
,
TestConfiguration
.
class
);
String
d
=
"@startuml\n"
;
for
(
TestConfiguration
tc
:
testConfigurations
)
{
d
+=
"rectangle \"Test Configuration\\n"
+
tc
.
getName
()+
"\" {\n"
;
...
...
@@ -416,27 +451,93 @@ public class Standalone {
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
/*
* @startuml
component Tester {
portout p1c
portout p2c
portout p3c
private
void
generateBehaviour
(
String
path
,
EObject
model
)
{
List
<
TestDescription
>
testDescriptions
=
EcoreUtil2
.
getAllContentsOfType
(
model
,
TestDescription
.
class
);
for
(
TestDescription
td
:
testDescriptions
)
{
String
d
=
"@startuml\n"
;
d
+=
"hide footbox\n"
;
d
+=
"title Foot Box removed\n"
;
TestConfiguration
tc
=
td
.
getTestConfiguration
();
for
(
var
i
:
tc
.
getComponentInstance
())
{
if
(
i
.
getRole
()
==
ComponentInstanceRole
.
TESTER
)
{
d
+=
"participant "
+
tc
.
getName
()+
"_"
+
i
.
getName
()+
" [\n == "
+
i
.
getRole
().
toString
()
+
"\n ----\n \"\""
+
i
.
getName
()
+
" : "
+
i
.
getType
().
getName
()
+
"\"\"\n]\n\n"
;
}
}
for
(
var
i
:
tc
.
getComponentInstance
())
{
if
(
i
.
getRole
()
==
ComponentInstanceRole
.
SUT
)
{
d
+=
"participant "
+
tc
.
getName
()+
"_"
+
i
.
getName
()+
" [\n == "
+
i
.
getRole
().
toString
()
+
"\n ----\n \"\""
+
i
.
getName
()
+
" : "
+
i
.
getType
().
getName
()
+
"\"\"\n]\n\n"
;
}
}
if
(
td
.
getBehaviourDescription
()!=
null
)
{
var
b
=
td
.
getBehaviourDescription
().
getBehaviour
();
try
{
d
+=
processBehaviour
(
castObject
(
b
.
getClass
(),
b
));
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Error: "
+
e
.
getMessage
());
}
}
component SUT {
portin p1d
portin p2d
portin p3d
d
+=
"@enduml"
;
//TODO: need to split behaviours..
System
.
out
.
println
(
d
);
try
{
//TODO: make configurable
Files
.
writeString
(
Path
.
of
(
path
+
"-"
+
td
.
getName
()+
"-behaviour.md"
),
d
);
}
catch
(
Exception
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
p1c <--> p1d
p2c <--> p2d
p3c <--> p3d
@enduml
}
}
private
<
T
>
T
castObject
(
Class
<
T
>
clazz
,
Object
object
)
{
return
(
T
)
object
;
}
private
String
processBehaviour
(
Behaviour
b
)
{
String
d
=
"' Not supported yet: "
+
b
.
getClass
().
getName
();
System
.
out
.
println
(
d
);
return
d
+
"\n"
;
}
private
String
processBehaviour
(
CompoundBehaviour
b
)
{
String
d
=
""
;
for
(
var
nested
:
b
.
getBlock
().
getBehaviour
())
{
d
+=
processBehaviour
(
castObject
(
nested
.
getClass
(),
nested
));
}
//TODO: handle prefixes and indentation?
return
d
;
}
private
String
processBehaviour
(
Message
b
)
{
var
sc
=
b
.
getSourceGate
().
getComponent
();
var
c
=
sc
.
container
().
getName
()+
"_"
+
sc
.
getName
();
var
tc
=
b
.
getTarget
().
get
(
0
).
getTargetGate
().
getComponent
();
var
t
=
tc
.
container
().
getName
()+
"_"
+
tc
.
getName
();
var
a
=
b
.
getArgument
();
String
d
=
""
;
//TODO: use node model untils to get text (needs processing)
d
+=
c
+
" -> "
+
t
+
" : "
+
b
.
toString
()+
"\n"
;
return
d
;
}
*/
}
private
String
processComponentInstance
(
ComponentInstance
i
)
{
String
c
=
"component \"<<"
+
i
.
getRole
().
getName
()+
">>\\n"
+
i
.
getName
()+
":"
+
i
.
getType
().
getName
()+
"\" { \n"
;
...
...
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