Skip to content
GitLab
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
TDL Open Source
TOP IDE
Compare revisions
f3d706781575163643acc7cb48adf3938540d12d...f54d5b9f3f220ec9241f2612defba6f20b0285df
Commits (2)
Updated TRI.
· 57dc92e6
Martti Käärik
authored
Feb 13, 2024
57dc92e6
Extended TRI implementation and code generation support.
· f54d5b9f
Martti Käärik
authored
Mar 01, 2024
f54d5b9f
Hide whitespace changes
Inline
Side-by-side
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/rt/core/MappingImpl.java
0 → 100644
View file @
f54d5b9f
package
org.etsi.mts.tdl.execution.java.rt.core
;
import
java.util.Hashtable
;
import
java.util.Map
;
import
org.etsi.mts.tdl.execution.java.tri.ElementAnnotation
;
import
org.etsi.mts.tdl.execution.java.tri.Mapping
;
public
class
MappingImpl
extends
Mapping
implements
TriImpl
<
MappingImpl
,
MappingImpl
>
{
private
String
mappingName
;
private
boolean
resource
;
private
boolean
parameter
;
private
String
uri
;
private
MappingImpl
container
;
private
Map
<
String
,
MappingImpl
>
parameters
=
new
Hashtable
<
String
,
MappingImpl
>();
public
MappingImpl
()
{
}
public
MappingImpl
(
String
mappingName
,
String
uri
)
{
this
.
mappingName
=
mappingName
;
this
.
uri
=
uri
;
}
@Override
public
String
getUri
()
{
return
uri
;
}
@Override
public
String
getMappingName
()
{
return
mappingName
;
}
public
MappingImpl
setIsResource
(
boolean
resource
)
{
this
.
resource
=
resource
;
return
this
;
}
public
MappingImpl
setIsParameter
(
boolean
parameter
)
{
this
.
parameter
=
parameter
;
return
this
;
}
@Override
public
boolean
isResource
()
{
return
resource
;
}
@Override
public
boolean
isParameter
()
{
return
parameter
;
}
public
MappingImpl
setResource
(
MappingImpl
container
)
{
this
.
container
=
container
;
return
this
;
}
@Override
public
MappingImpl
getResource
()
{
return
container
;
}
@Override
public
MappingImpl
setParameter
(
String
name
,
MappingImpl
mapping
)
{
this
.
parameters
.
put
(
name
,
mapping
);
return
this
;
}
@Override
public
MappingImpl
getParameter
(
String
name
)
{
return
this
.
parameters
.
get
(
name
);
}
@Override
public
MappingImpl
setName
(
String
name
,
String
qualifiedName
)
{
this
.
name
=
name
;
return
this
;
}
@Override
public
MappingImpl
addAnnotation
(
String
key
,
String
value
)
{
this
.
annotations
.
add
(
new
ElementAnnotation
(
key
,
value
));
return
this
;
}
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/rt/core/TestControl.java
View file @
f54d5b9f
...
...
@@ -37,7 +37,8 @@ public class TestControl {
public
RuntimeHelper
runtimeHelper
;
private
Connection
[]
connections
;
private
Map
<
Connection
,
ReceiverHub
>
receiverHubs
=
Collections
.
synchronizedMap
(
new
Hashtable
<
Connection
,
ReceiverHub
>());
private
Map
<
Connection
,
ReceiverHub
>
receiverHubs
=
Collections
.
synchronizedMap
(
new
Hashtable
<
Connection
,
ReceiverHub
>());
protected
ExecutorCompletionService
<
ExecutionResult
>
completionService
;
protected
ExecutorService
executor
;
...
...
@@ -47,6 +48,8 @@ public class TestControl {
private
List
<
ExceptionalBehaviour
>
exceptionalBehaviours
=
Collections
.
synchronizedList
(
new
ArrayList
<
ExceptionalBehaviour
>());
protected
Map
<
String
,
TypeImpl
>
types
=
new
Hashtable
<
String
,
TypeImpl
>();
public
TestControl
(
com
.
google
.
inject
.
Module
guiceModule
)
{
super
();
...
...
@@ -61,11 +64,11 @@ public class TestControl {
this
.
executor
=
Executors
.
newCachedThreadPool
();
this
.
completionService
=
new
ExecutorCompletionService
<
ExecutionResult
>(
executor
);
}
protected
<
A
>
A
getInstance
(
Class
<
A
>
clazz
)
{
return
this
.
injector
.
getInstance
(
clazz
);
}
private
ReceiverHub
getReceiver
(
Connection
connection
)
{
ReceiverHub
hub
=
this
.
receiverHubs
.
get
(
connection
);
if
(
hub
==
null
)
...
...
@@ -76,7 +79,7 @@ public class TestControl {
public
void
configure
(
Connection
[]
connections
)
{
this
.
systemAdapter
.
configure
(
connections
);
this
.
connections
=
connections
;
this
.
receiverHubs
.
values
().
forEach
(
r
->
r
.
stop
());
this
.
receiverHubs
.
clear
();
for
(
Connection
c
:
connections
)
{
...
...
@@ -93,10 +96,12 @@ public class TestControl {
Data
data
=
hub
.
receive
(
null
,
false
);
return
data
!=
null
?
new
InteractionResult
(
data
)
:
null
;
}
};
hub
.
setAnyReceiver
(
anyReceiver
);
}
declareTypes
();
}
public
Connection
getConnection
(
String
testerComponentName
,
String
testerGateName
,
String
remoteComponentName
,
...
...
@@ -164,7 +169,7 @@ public class TestControl {
return
future
;
}
}
public
List
<
Future
<
ExecutionResult
>>
executeExceptionals
()
{
List
<
Future
<
ExecutionResult
>>
futures
=
new
ArrayList
<>();
exceptionalBehaviours
.
forEach
(
exc
->
futures
.
add
(
exc
.
execute
()));
...
...
@@ -234,7 +239,6 @@ public class TestControl {
return
receive
(
expected
,
connection
,
true
);
}
public
ExecutionCallable
receive
(
Data
expected
,
Connection
connection
,
boolean
isTrigger
)
{
ExecutionCallableWithDefaults
c
=
new
ExecutionCallableWithDefaults
()
{
@Override
...
...
@@ -367,4 +371,19 @@ public class TestControl {
f2
.
cancel
(
true
);
}
}
/**
* This is called once before each test case. Implemented by generated code to
* declare types and mappings if using unmapped data in TRI.
*/
protected
void
declareTypes
()
{
}
protected
void
addType
(
String
name
,
TypeImpl
type
)
{
this
.
types
.
put
(
name
,
type
);
}
protected
TypeImpl
getType
(
String
name
)
{
return
this
.
types
.
get
(
name
);
}
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/rt/core/TriImpl.java
0 → 100644
View file @
f54d5b9f
package
org.etsi.mts.tdl.execution.java.rt.core
;
public
interface
TriImpl
<
I
,
P
>
{
I
setName
(
String
name
,
String
qualifiedName
);
I
addAnnotation
(
String
key
,
String
value
);
I
setParameter
(
String
name
,
P
mapping
);
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/rt/core/TypeImpl.java
0 → 100644
View file @
f54d5b9f
package
org.etsi.mts.tdl.execution.java.rt.core
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.Map
;
import
org.etsi.mts.tdl.execution.java.tri.Data
;
import
org.etsi.mts.tdl.execution.java.tri.ElementAnnotation
;
import
org.etsi.mts.tdl.execution.java.tri.Mapping
;
import
org.etsi.mts.tdl.execution.java.tri.Type
;
import
org.etsi.mts.tdl.execution.java.tri.Value
;
public
class
TypeImpl
extends
Type
implements
TriImpl
<
TypeImpl
,
TypeImpl
>
{
private
boolean
structure
=
false
;
private
boolean
collection
=
false
;
private
boolean
enumerated
=
false
;
private
Map
<
String
,
TypeImpl
>
parameters
=
new
Hashtable
<
String
,
TypeImpl
>();
private
TypeImpl
itemType
=
null
;
private
List
<
Data
<
Type
,
Value
>>
enumLiterals
=
new
ArrayList
<
Data
<
Type
,
Value
>>();
private
MappingImpl
mapping
;
public
TypeImpl
setIsStructure
(
boolean
structure
)
{
this
.
structure
=
structure
;
return
this
;
}
public
TypeImpl
setIsCollection
(
boolean
collection
)
{
this
.
collection
=
collection
;
return
this
;
}
public
TypeImpl
setIsEnum
(
boolean
enumerated
)
{
this
.
enumerated
=
enumerated
;
return
this
;
}
@Override
public
boolean
isStructure
()
{
return
this
.
structure
;
}
@Override
public
boolean
isCollection
()
{
return
this
.
collection
;
}
@Override
public
boolean
isEnum
()
{
return
this
.
enumerated
;
}
public
TypeImpl
setMapping
(
Mapping
mapping
)
{
this
.
mapping
=
(
MappingImpl
)
mapping
;
return
this
;
}
@Override
public
MappingImpl
getMapping
()
{
return
mapping
;
}
@Override
public
TypeImpl
setParameter
(
String
name
,
TypeImpl
type
)
{
this
.
parameters
.
put
(
name
,
type
);
return
this
;
}
@Override
public
TypeImpl
getParameter
(
String
name
)
{
return
this
.
parameters
.
get
(
name
);
}
@Override
public
Collection
<
String
>
getParameters
()
{
return
this
.
parameters
.
keySet
();
}
public
TypeImpl
setItemType
(
TypeImpl
itemType
)
{
this
.
itemType
=
itemType
;
return
this
;
}
@Override
public
TypeImpl
getItemType
()
{
return
this
.
itemType
;
}
@Override
public
List
<
Data
<
Type
,
Value
>>
getEnumLiterals
()
{
return
this
.
enumLiterals
;
}
public
TypeImpl
addEnumLiteral
(
ValueImpl
literal
)
{
this
.
enumLiterals
.
add
(
new
Data
<
Type
,
Value
>(
this
,
literal
));
return
this
;
}
@Override
public
TypeImpl
setName
(
String
name
,
String
qualifiedName
)
{
this
.
name
=
name
;
this
.
qualifiedName
=
qualifiedName
;
return
this
;
}
@Override
public
TypeImpl
addAnnotation
(
String
key
,
String
value
)
{
this
.
annotations
.
add
(
new
ElementAnnotation
(
key
,
value
));
return
this
;
}
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/rt/core/ValueImpl.java
0 → 100644
View file @
f54d5b9f
package
org.etsi.mts.tdl.execution.java.rt.core
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.Map
;
import
org.etsi.mts.tdl.execution.java.tri.Data
;
import
org.etsi.mts.tdl.execution.java.tri.ElementAnnotation
;
import
org.etsi.mts.tdl.execution.java.tri.Mapping
;
import
org.etsi.mts.tdl.execution.java.tri.Type
;
import
org.etsi.mts.tdl.execution.java.tri.Value
;
public
class
ValueImpl
extends
Value
implements
TriImpl
<
ValueImpl
,
Data
<
Type
,
Value
>>
{
private
TypeImpl
type
;
private
boolean
collection
=
false
;
private
boolean
structure
=
false
;
private
Object
value
=
null
;
private
Map
<
String
,
Data
<
Type
,
Value
>>
parameters
=
new
Hashtable
<
String
,
Data
<
Type
,
Value
>>();
private
List
<
Data
<
Type
,
Value
>>
items
=
new
ArrayList
<
Data
<
Type
,
Value
>>();
private
MappingImpl
mapping
;
public
ValueImpl
()
{
}
public
ValueImpl
(
TypeImpl
type
)
{
this
.
type
=
type
;
}
public
ValueImpl
setType
(
TypeImpl
type
)
{
this
.
type
=
type
;
return
this
;
}
public
ValueImpl
setIsCollection
(
boolean
collection
)
{
this
.
collection
=
collection
;
return
this
;
}
public
ValueImpl
setIsStructure
(
boolean
structure
)
{
this
.
structure
=
structure
;
return
this
;
}
@Override
public
boolean
isCollection
()
{
return
this
.
collection
;
}
@Override
public
boolean
isStructure
()
{
return
this
.
structure
;
}
public
ValueImpl
setMapping
(
Mapping
mapping
)
{
this
.
mapping
=
(
MappingImpl
)
mapping
;
return
this
;
}
@Override
public
MappingImpl
getMapping
()
{
return
mapping
;
}
@Override
public
Object
getValue
()
{
return
this
.
value
;
}
public
ValueImpl
setValue
(
Object
value
)
{
this
.
value
=
value
;
return
this
;
}
@Override
public
Collection
<
String
>
getParameters
()
{
return
this
.
parameters
.
keySet
();
}
@Override
public
Data
<
Type
,
Value
>
getParameter
(
String
name
)
{
return
this
.
parameters
.
get
(
name
);
}
@Override
public
ValueImpl
setParameter
(
String
name
,
Data
<
Type
,
Value
>
value
)
{
this
.
parameters
.
put
(
name
,
value
);
return
this
;
}
@Override
public
List
<
Data
<
Type
,
Value
>>
getItems
()
{
return
this
.
items
;
}
public
ValueImpl
addItem
(
Data
<
Type
,
Value
>
item
)
{
this
.
items
.
add
(
item
);
return
this
;
}
public
ValueImpl
setItems
(
List
<
Data
<
Type
,
Value
>>
items
)
{
this
.
items
=
items
;
return
this
;
}
@Override
public
ValueImpl
setName
(
String
name
,
String
qualifiedName
)
{
this
.
name
=
name
;
this
.
qualifiedName
=
qualifiedName
;
return
this
;
}
@Override
public
ValueImpl
addAnnotation
(
String
key
,
String
value
)
{
this
.
annotations
.
add
(
new
ElementAnnotation
(
key
,
value
));
return
this
;
}
public
Data
<
Type
,
Value
>
asData
()
{
return
new
Data
<
Type
,
Value
>(
type
,
this
);
}
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/tri/Argument.java
View file @
f54d5b9f
...
...
@@ -15,6 +15,11 @@ public class Argument<T, V> extends Data<T, V> {
this
.
parameterName
=
parameterName
;
}
public
Argument
(
Data
<
T
,
V
>
data
,
String
parameterName
)
{
super
(
data
.
getType
(),
data
.
getValue
());
this
.
parameterName
=
parameterName
;
}
public
String
getParameterName
()
{
return
parameterName
;
}
...
...
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/tri/Element.java
View file @
f54d5b9f
...
...
@@ -14,7 +14,7 @@ public class Element {
/**
* The name of the element as specified in TDL model.
*/
p
ublic
String
name
;
p
rotected
String
name
;
/**
* The annotations assigned to the element as specified in TDL model.
...
...
@@ -27,4 +27,8 @@ public class Element {
public
Element
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getName
()
{
return
name
;
}
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/tri/Mapping.java
0 → 100644
View file @
f54d5b9f
package
org.etsi.mts.tdl.execution.java.tri
;
/**
* Representation of a TDL model element of class <i>DataResourceMapping</i>,
* <i>DataElementMapping</i> or <i>ParameterMapping</i>.
*/
public
abstract
class
Mapping
extends
Element
{
/**
* Get the name applied to the associated <i>DataResourceMapping</i> element
* using the predefined <i>MappingName</i> annotation.
*
* @return A distinctive name for this mapping.
*/
public
abstract
String
getMappingName
();
/**
* If this is a resource mapping.
*
* @return <b>true</b> if this type represents a <i>DataResourceMapping</i>
* element.
*/
public
abstract
boolean
isResource
();
/**
* If this is a parameter mapping.
*
* @return <b>true</b> if this type represents a <i>ParameterMapping</i>
* element.
*/
public
abstract
boolean
isParameter
();
/**
* Get the type-sepcific URI for this mapping.
*
* @return The URI of this mapping as specified in corresponding model element.
*/
public
abstract
String
getUri
();
/**
* Get the resource mapping for this data mapping.
*
* @return The <code>Mapping</code> representing the <i>DataResourceMapping</i>
* element referenced by the associated <i>DataElementMapping</i>
* element.
*/
public
abstract
Mapping
getResource
();
/**
* Get the parameter mappings of this data mapping.
*
* @param parameterName Name of the parameter as returned by
* {@link Type#getParameters() Type.getParameters()} or
* {@link Value#getParameters() Value.getParameters()}.
* @return A <code>Mapping</code> representing a <i>ParameterMapping</i>
* element.
*/
public
abstract
Mapping
getParameter
(
String
parameterName
);
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/tri/NamedElement.java
View file @
f54d5b9f
...
...
@@ -9,7 +9,7 @@ public class NamedElement extends Element {
/**
* The qualified name of the element as specified in TDL model.
*/
p
ublic
String
qualifiedName
;
p
rotected
String
qualifiedName
;
public
NamedElement
()
{
}
...
...
@@ -18,4 +18,8 @@ public class NamedElement extends Element {
super
(
name
);
this
.
qualifiedName
=
qualifiedName
;
}
public
String
getQualifiedName
()
{
return
qualifiedName
;
}
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/tri/SpecialValue.java
0 → 100644
View file @
f54d5b9f
package
org.etsi.mts.tdl.execution.java.tri
;
/**
* Designates a sub-class of <i>SpecialValueUse</i>.
*/
public
enum
SpecialValue
{
AnyValue
,
AnyValueOrOmit
,
OmitValue
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/tri/Type.java
0 → 100644
View file @
f54d5b9f
package
org.etsi.mts.tdl.execution.java.tri
;
import
java.util.Collection
;
import
java.util.List
;
/**
* Representation of a TDL model element of class <i>DataType</i> and its
* sub-classes.
*/
public
abstract
class
Type
extends
NamedElement
{
/**
* If this type is a structure.
*
* @return <b>true</b> if this type represents a <i>StructureDataType</i>
* element.
*/
public
abstract
boolean
isStructure
();
/**
* If this type is a collection.
*
* @return <b>true</b> if this type represents a <i>CollectionDataType</i>
* element.
*/
public
abstract
boolean
isCollection
();
/**
* If this type is an enum.
*
* @return <b>true</b> if this type represents a <i>EnumDataType</i> element.
*/
public
abstract
boolean
isEnum
();
/**
* Get the data mapping chosen for the runtime. The mapping that is chosen is
* implementation specific.
*
* @return A <code>Mapping</code> representing a <i>DataElementMapping</i>
* element.
*/
public
abstract
Mapping
getMapping
();
/**
* Get the names of members of this structured type. Includes all inherited
* members as well.
*
* @return Collection of names from the <i>Member</i> elements contained or
* inherited in the corresponding <i>StructuredDataType</i> element.
*/
public
abstract
Collection
<
String
>
getParameters
();
/**
* Get the type of a parameter.
*
* @param parameterName Name of the parameter as returned by
* {@link #getParameters() getParameters()}.
* @return The <code>Type</code> of the parameter representing the
* <i>DataType</i> of the <i>Member</i> element corresponding to the
* parameter.
*/
public
abstract
Type
getParameter
(
String
parameterName
);
/**
* Get the type of items of this collection type.
*
* @return The <code>Type</code> of the items contained in a collection of this
* <code>Type</code>.
*/
public
abstract
Type
getItemType
();
/**
* Get the literal values of this enumerated type.
*
* @return The <code>Data</code> objects representing the
* <i>SimpleDataInstance</i> elements contained in the corresponding
* <i>EnumDataType</i> element.
*/
public
abstract
List
<
Data
<
Type
,
Value
>>
getEnumLiterals
();
}
plugins/org.etsi.mts.tdl.execution.java.runtime/src/org/etsi/mts/tdl/execution/java/tri/Value.java
0 → 100644
View file @
f54d5b9f
package
org.etsi.mts.tdl.execution.java.tri
;
import
java.util.Collection
;
import
java.util.List
;
/**
* Representation of a TDL model element of class <i>DataInstance</i> or
* <i>DataUse</i> and their sub-classes.
*/
public
abstract
class
Value
extends
NamedElement
{
/**
* If this value is a structure.
*
* @return <b>true</b> if the type of this value represents a
* <i>StructureDataType</i> element.
*/
public
abstract
boolean
isStructure
();
/**
* If this value is a collection.
*
* @return <b>true</b> if the type of this value represents a
* <i>CollectionDataType</i> element.
*/
public
abstract
boolean
isCollection
();
/**
* Get the data mapping chosen for the runtime. The mapping that is chosen is
* implementation specific.
*
* @return A <code>Mapping</code> representing a <i>DataElementMapping</i>
* element.
*/
public
abstract
Mapping
getMapping
();
/**
* Get the primitive or special value of this value object.
*
* @return A <code>String</code>, a <code>Boolean</code> or any other boxed
* primitive value or an instance of {@link SpecialValue SpecialValue}.
*/
public
abstract
Object
getValue
();
/**
* Get the names of members of the structured type of this value. Only returns
* the parameters that have a value assigned.
*
* @return Collection of names from the <i>MemberAssignment</i> or
* <i>ParameterBinding</i> elements contained in the corresponding
* <i>DataInstance</i> or <i>DataUse</i> element.
*/
public
abstract
Collection
<
String
>
getParameters
();
/**
* Get the value data of a parameter.
*
* @param parameterName Name of the parameter as returned by
* {@link #getParameters() getParameters()}.
* @return The <code>Value</code> of the parameter wrapped in <code>Data</code>
* object.
*/
public
abstract
Data
<
Type
,
Value
>
getParameter
(
String
parameterName
);
/**
* Get the values contained in this collection value.
*
* @return The <code>Value</code>s of the items wrapped in <code>Data</code>
* objects.
*/
public
abstract
List
<
Data
<
Type
,
Value
>>
getItems
();
}
plugins/org.etsi.mts.tdl.execution.java/src/org/etsi/mts/tdl/execution/java/codegen/JUnitTestGenerator.java
View file @
f54d5b9f
...
...
@@ -19,6 +19,7 @@ import org.etsi.mts.tdl.Action;
import
org.etsi.mts.tdl.ActionBehaviour
;
import
org.etsi.mts.tdl.ActionReference
;
import
org.etsi.mts.tdl.AlternativeBehaviour
;
import
org.etsi.mts.tdl.Annotation
;
import
org.etsi.mts.tdl.Assertion
;
import
org.etsi.mts.tdl.Assignment
;
import
org.etsi.mts.tdl.AtomicBehaviour
;
...
...
@@ -77,6 +78,7 @@ import org.etsi.mts.tdl.SingleCombinedBehaviour;
import
org.etsi.mts.tdl.SpecialValueUse
;
import
org.etsi.mts.tdl.Stop
;
import
org.etsi.mts.tdl.StructuredDataInstance
;
import
org.etsi.mts.tdl.StructuredDataType
;
import
org.etsi.mts.tdl.Target
;
import
org.etsi.mts.tdl.TestConfiguration
;
import
org.etsi.mts.tdl.TestDescription
;
...
...
@@ -136,6 +138,8 @@ public class JUnitTestGenerator extends Renderer {
private
ComponentInstance
currentTester
=
null
;
private
Map
<
DataType
,
String
>
declaredTypes
=
new
Hashtable
<
DataType
,
String
>();
public
JUnitTestGenerator
(
Package
model
,
Settings
settings
)
{
super
(
settings
.
outputFile
,
settings
.
outPackage
);
this
.
model
=
model
;
...
...
@@ -156,7 +160,7 @@ public class JUnitTestGenerator extends Renderer {
List
<
TestDescription
>
tdList
=
new
ArrayList
<
TestDescription
>();
gatherPackageableElements
(
model
,
false
,
e
->
{
if
(
e
instanceof
TestDescription
)
if
(((
TestDescription
)
e
).
isIsLocallyOrdered
())
if
(((
TestDescription
)
e
).
isIsLocallyOrdered
())
tdList
.
add
((
TestDescription
)
e
);
});
...
...
@@ -184,11 +188,15 @@ public class JUnitTestGenerator extends Renderer {
}
protected
DataElementMapping
getMapping
(
MappableDataElement
e
)
{
return
getMapping
(
e
,
JAVA_MAPPING_VALUE
);
}
protected
DataElementMapping
getMapping
(
MappableDataElement
e
,
String
mappingName
)
{
Set
<
DataElementMapping
>
mappings
=
this
.
elementMappings
.
get
(
e
);
if
(
mappings
!=
null
&&
!
mappings
.
isEmpty
())
{
for
(
DataElementMapping
m
:
mappings
)
{
if
(
m
.
getDataResourceMapping
().
getAnnotation
().
stream
().
anyMatch
(
a
->
a
.
getKey
().
getName
().
equals
(
MAPPING_KEY
)
&&
a
.
getValue
().
equals
(
JAVA_MAPPING_VALUE
)))
a
->
a
.
getKey
().
getName
().
equals
(
MAPPING_KEY
)
&&
a
.
getValue
().
equals
IgnoreCase
(
mappingName
)))
return
m
;
}
}
...
...
@@ -221,10 +229,35 @@ public class JUnitTestGenerator extends Renderer {
return
null
;
}
private
boolean
isUnmapped
()
{
return
this
.
settings
.
unmappedData
;
}
@Override
protected
String
getElementName
(
Element
e
)
{
if
(
isUnmapped
())
{
if
(
e
instanceof
DataType
)
{
return
CORE_PACKAGE
+
".ValueImpl"
;
}
}
return
super
.
getElementName
(
e
);
}
private
boolean
hasAnnotation
(
Element
e
,
String
keyName
)
{
return
e
.
getAnnotation
().
stream
().
anyMatch
(
a
->
a
.
getKey
().
getName
().
equals
(
keyName
));
}
private
Annotation
getAnnotation
(
Element
e
,
String
keyName
)
{
Optional
<
Annotation
>
op
=
e
.
getAnnotation
().
stream
().
filter
(
a
->
a
.
getKey
().
getName
().
equals
(
keyName
)).
findAny
();
if
(
op
.
isPresent
())
return
op
.
get
();
return
null
;
}
private
boolean
isVerdict
(
DataType
t
)
{
return
t
.
getQualifiedName
().
equals
(
"TDL::Verdict"
);
}
protected
void
addImport
(
DataElementMapping
m
,
Set
<
String
>
imports
)
{
if
(
m
==
null
)
return
;
...
...
@@ -299,14 +332,20 @@ public class JUnitTestGenerator extends Renderer {
private
void
writeComponentType
(
TestConfiguration
tc
,
ComponentType
ct
,
String
className
)
{
ct
.
getVariable
().
forEach
(
v
->
{
line
(
"public "
+
getElementName
(
v
.
getDataType
())
+
" "
+
getElementName
(
v
)
+
";"
);
append
(
"public "
+
getElementName
(
v
.
getDataType
())
+
" "
+
getElementName
(
v
));
if
(
isUnmapped
())
{
append
(
" = new "
);
append
(
CORE_PACKAGE
+
".ValueImpl"
);
append
(
"();"
);
}
line
(
";"
);
});
newLine
();
ct
.
getTimer
().
forEach
(
t
->
{
String
timerClass
=
CORE_PACKAGE
+
".Timer "
;
line
(
"public "
+
timerClass
+
getTimerName
(
t
)
+
" = new "
+
timerClass
+
"(TimeUnit.Second"
+
", \""
+
t
.
getName
()
+
"\", \""
+
t
.
getQualifiedName
()
+
"\");"
);
line
(
"public "
+
timerClass
+
getTimerName
(
t
)
+
" = new "
+
timerClass
+
"(TimeUnit.Second"
+
", \""
+
t
.
getName
()
+
"\", \""
+
t
.
getQualifiedName
()
+
"\");"
);
});
newLine
();
...
...
@@ -390,6 +429,10 @@ public class JUnitTestGenerator extends Renderer {
newLine
();
writeTestConfiguration
(
td
);
newLine
();
writeTypes
(
td
);
newLine
();
writeTestDescription
(
td
);
...
...
@@ -502,6 +545,153 @@ public class JUnitTestGenerator extends Renderer {
append
(
"getGateReference(\""
+
tester
.
getComponent
().
getName
()
+
"\", \""
+
tester
.
getGate
().
getName
()
+
"\")"
);
}
private
void
writeTypes
(
TestDescription
tc
)
{
if
(!
isUnmapped
())
return
;
append
(
"protected void declareTypes()"
);
blockOpen
();
TreeIterator
<
EObject
>
i
=
tc
.
eAllContents
();
while
(
i
.
hasNext
())
{
EObject
e
=
i
.
next
();
if
(
e
instanceof
DataUse
)
{
DataType
type
=
((
DataUse
)
e
).
resolveDataType
();
if
(
type
!=
null
)
declareType
(
type
,
declaredTypes
);
}
else
if
(
e
instanceof
Variable
)
{
declareType
(((
Variable
)
e
).
getDataType
(),
declaredTypes
);
}
}
// XXX
// final List<String> connectionNames = new ArrayList<String>();
// config.getConnection().forEach(conn -> {
// String connectionName = getElementName(conn);
// connectionNames.add(connectionName);
//
// List<GateReference> endpoints = conn.getEndPoint();
// append("Connection " + connectionName + " = new Connection");
// callOpen();
// line("\"" + conn.getName() + "\", ");
// writeGateReference(endpoints.get(0));
// line(", ");
// writeGateReference(endpoints.get(1));
// callClose();
//
// });
// append("configure(new Connection[] {");
// boolean first = true;
// for (String cn : connectionNames) {
// if (!first)
// append(", ");
// first = false;
// append(cn);
// }
// line("});");
blockClose
();
newLine
();
}
private
String
declareType
(
DataType
t
,
Map
<
DataType
,
String
>
declaredTypes
)
{
if
(
declaredTypes
.
containsKey
(
t
))
return
declaredTypes
.
get
(
t
);
String
name
=
super
.
getElementName
(
t
);
declaredTypes
.
put
(
t
,
name
);
if
(
t
instanceof
StructuredDataType
)
{
for
(
Member
m
:
((
StructuredDataType
)
t
).
allMembers
())
{
DataType
mType
=
m
.
getDataType
();
declareType
(
mType
,
declaredTypes
);
}
}
else
if
(
t
instanceof
CollectionDataType
)
{
DataType
iType
=
((
CollectionDataType
)
t
).
getItemType
();
declareType
(
iType
,
declaredTypes
);
}
//TODO add mapping name to mapping
DataElementMapping
mapping
=
getMapping
(
t
);
if
(
mapping
==
null
)
mapping
=
getMapping
(
t
,
settings
.
useMapping
);
String
mappingName
=
name
+
"_mapping"
;
if
(
mapping
!=
null
)
writeMapping
(
mapping
,
mappingName
,
false
);
line
(
CORE_PACKAGE
+
".TypeImpl "
+
name
+
" = new "
+
CORE_PACKAGE
+
".TypeImpl()"
);
writeSetName
(
t
);
writeAddAnnotations
(
t
);
if
(
mapping
!=
null
)
{
line
(
".setMapping("
+
mappingName
+
")"
);
}
if
(
t
instanceof
StructuredDataType
)
{
line
(
".setIsStructure(true)"
);
for
(
Member
m
:
((
StructuredDataType
)
t
).
allMembers
())
{
String
mTypeName
=
declaredTypes
.
get
(
m
.
getDataType
());
line
(
".setParameter(\""
+
m
.
getName
()
+
"\", "
+
mTypeName
+
")"
);
}
}
else
if
(
t
instanceof
CollectionDataType
)
{
line
(
".setIsCollection(true)"
);
String
iTypeName
=
declaredTypes
.
get
(((
CollectionDataType
)
t
).
getItemType
());
line
(
".setItemType("
+
iTypeName
+
")"
);
}
line
(
";"
);
line
(
"addType(\""
+
name
+
"\", "
+
name
+
");"
);
return
name
;
}
private
void
writeMapping
(
DataElementMapping
mapping
,
String
mappingVarName
,
boolean
inline
)
{
Annotation
nameAnnotation
=
getAnnotation
(
mapping
.
getDataResourceMapping
(),
MAPPING_KEY
);
String
name
=
nameAnnotation
!=
null
?
nameAnnotation
.
getValue
()
:
null
;
if
(!
inline
)
append
(
CORE_PACKAGE
+
".MappingImpl "
+
mappingVarName
+
" = "
);
append
(
"new "
+
CORE_PACKAGE
+
".MappingImpl("
);
append
(
"\""
+
name
+
"\", "
);
// XXX
String
uri
=
mapping
.
getElementURI
().
replaceAll
(
"\\n|\\r"
,
" "
).
replaceAll
(
"\\\\"
,
"_"
);
append
(
"\""
+
uri
+
"\""
);
line
(
")"
);
DataResourceMapping
rsMapping
=
mapping
.
getDataResourceMapping
();
append
(
".setResource"
);
blockOpenParen
();
line
(
"new "
+
CORE_PACKAGE
+
".MappingImpl(\""
+
name
+
"\", \""
+
rsMapping
.
getResourceURI
()
+
"\")"
);
line
(
".setIsResource(true)"
);
writeAddAnnotations
(
rsMapping
);
blockCloseParen
();
for
(
ParameterMapping
pMapping
:
mapping
.
getParameterMapping
())
{
String
pName
=
pMapping
.
getParameter
().
getName
();
append
(
".setParameter"
);
blockOpenParen
();
line
(
"\""
+
pName
+
"\", "
);
line
(
"new "
+
CORE_PACKAGE
+
".MappingImpl(\""
+
name
+
"\", \""
+
pMapping
.
getParameterURI
()
+
"\")"
);
line
(
".setIsParameter(true)"
);
writeAddAnnotations
(
pMapping
);
blockCloseParen
();
}
if
(!
inline
)
line
(
";"
);
}
private
void
writeSetName
(
NamedElement
e
)
{
line
(
".setName(\""
+
e
.
getName
()
+
"\", \""
+
e
.
getQualifiedName
()
+
"\")"
);
}
private
void
writeAddAnnotations
(
Element
e
)
{
for
(
Annotation
a
:
e
.
getAnnotation
())
{
String
value
=
a
.
getValue
();
line
(
".addAnnotation(\""
+
a
.
getKey
().
getQualifiedName
()
+
"\", "
+
(
value
!=
null
?
"\""
+
a
.
getValue
()
+
"\""
:
"null"
)
+
")"
);
}
}
private
void
writeElement
(
Element
e
)
{
append
(
"new Element(\""
+
e
.
getName
()
+
"\")"
);
}
...
...
@@ -1409,31 +1599,49 @@ public class JUnitTestGenerator extends Renderer {
}
if
(
type
==
null
&&
!
isTime
)
{
// XXX meta-model problem
if
(
d
instanceof
LiteralValueUse
)
{
LiteralValueUse
ld
=
(
LiteralValueUse
)
d
;
if
(
ld
.
getBoolValue
()
!=
null
)
line
(
"boolean"
+
" "
+
varName
+
";"
);
else
if
(
ld
.
getIntValue
()
!=
null
)
line
(
"int"
+
" "
+
varName
+
";"
);
else
line
(
"String"
+
" "
+
varName
+
";"
);
}
else
if
(
d
instanceof
PredefinedFunctionCall
)
{
line
(
"// TODO Meta-model problem: DataUse.resolveDataType() return null"
);
line
(
getPredefinedFunctionType
(((
PredefinedFunctionCall
)
d
).
getFunction
())
+
" "
+
varName
+
";"
);
if
(
isUnmapped
())
{
line
(
CORE_PACKAGE
+
".ValueImpl"
+
" "
+
varName
+
";"
);
}
else
{
line
(
"// TODO Meta-model problem: DataUse.resolveDataType() return null"
);
line
(
"String"
+
" "
+
varName
+
";"
);
// XXX meta-model problem
if
(
d
instanceof
LiteralValueUse
)
{
LiteralValueUse
ld
=
(
LiteralValueUse
)
d
;
if
(
ld
.
getBoolValue
()
!=
null
)
line
(
"boolean"
+
" "
+
varName
+
";"
);
else
if
(
ld
.
getIntValue
()
!=
null
)
line
(
"int"
+
" "
+
varName
+
";"
);
else
line
(
"String"
+
" "
+
varName
+
";"
);
}
else
if
(
d
instanceof
PredefinedFunctionCall
)
{
line
(
"// TODO Meta-model problem: DataUse.resolveDataType() return null"
);
line
(
getPredefinedFunctionType
(((
PredefinedFunctionCall
)
d
).
getFunction
())
+
" "
+
varName
+
";"
);
}
else
{
line
(
"// TODO Meta-model problem: DataUse.resolveDataType() return null"
);
line
(
"String"
+
" "
+
varName
+
";"
);
}
}
}
else
if
(
type
instanceof
Time
||
isTime
)
line
(
"long "
+
varName
+
";"
);
else
if
(
type
instanceof
CollectionDataType
)
line
(
"java.util.List<"
+
getElementName
(((
CollectionDataType
)
type
).
getItemType
())
+
"> "
+
varName
+
";"
);
else
line
(
getElementName
(
type
)
+
" "
+
varName
+
";"
);
else
if
(
type
instanceof
CollectionDataType
)
{
if
(
isUnmapped
())
{
line
(
CORE_PACKAGE
+
".ValueImpl"
+
" "
+
varName
+
";"
);
}
else
{
line
(
"java.util.List<"
+
getElementName
(((
CollectionDataType
)
type
).
getItemType
())
+
"> "
+
varName
+
";"
);
}
}
else
{
if
(
isUnmapped
())
{
line
(
CORE_PACKAGE
+
".ValueImpl"
+
" "
+
varName
+
";"
);
}
else
{
line
(
getElementName
(
type
)
+
" "
+
varName
+
";"
);
}
}
dataUseVariables
.
put
(
d
,
varName
);
}
...
...
@@ -1469,7 +1677,7 @@ public class JUnitTestGenerator extends Renderer {
initializeDataUse
(
idx
,
dataUseVariables
);
}
if
(
d
instanceof
DataElementUse
)
{
for
(
DataUse
item:
((
DataElementUse
)
d
).
getItem
())
{
for
(
DataUse
item
:
((
DataElementUse
)
d
).
getItem
())
{
initializeDataUse
(
item
,
dataUseVariables
);
}
}
...
...
@@ -1481,9 +1689,6 @@ public class JUnitTestGenerator extends Renderer {
if
(!
dataUseVariables
.
containsKey
(
d
))
declareDataUse
(
d
,
dataUseVariables
,
""
);
String
ref
=
dataUseVariables
.
get
(
d
);
append
(
ref
);
append
(
" = "
);
DataInstance
dataInstance
=
null
;
DataType
dataType
=
null
;
...
...
@@ -1518,8 +1723,11 @@ public class JUnitTestGenerator extends Renderer {
else
if
(
element
instanceof
PredefinedFunction
)
predefinedFunction
=
(
PredefinedFunction
)
element
;
else
throw
new
RuntimeException
(
"Unsupported element in DataElementUse "
+
d
.
getName
());
else
{
dataType
=
d
.
resolveDataType
();
if
(
dataType
==
null
)
throw
new
RuntimeException
(
"Unresolved type of DataElementUse "
+
d
.
getName
());
}
}
else
if
(
d
instanceof
DataInstanceUse
)
{
dataInstance
=
((
DataInstanceUse
)
d
).
getDataInstance
();
...
...
@@ -1533,11 +1741,20 @@ public class JUnitTestGenerator extends Renderer {
predefinedFunction
=
((
PredefinedFunctionCall
)
d
).
getFunction
();
}
String
ref
=
dataUseVariables
.
get
(
d
);
append
(
ref
);
if
(!
isUnmapped
())
{
append
(
" = "
);
}
String
typeName
=
declaredTypes
.
get
(
d
.
resolveDataType
());
String
unmappedDataInitializer
=
" = new "
+
CORE_PACKAGE
+
".ValueImpl(getType(\""
+
typeName
+
"\"))"
;
if
(
dataInstance
!=
null
)
{
DataElementMapping
m
=
getMapping
(
dataInstance
);
if
(
m
==
null
)
{
DataType
t
=
dataInstance
.
getDataType
();
if
(
t
.
getQualifiedName
().
equals
(
"TDL::
Verdict
"
))
{
if
(
is
Verdict
(
t
))
{
append
(
"Verdict."
+
dataInstance
.
getName
());
}
else
...
...
@@ -1545,10 +1762,20 @@ public class JUnitTestGenerator extends Renderer {
}
else
{
// TODO instance function
String
classQName
=
m
.
getDataResourceMapping
().
getResourceURI
();
append
(
classQName
+
"."
+
m
.
getElementURI
());
if
(
hasAnnotation
(
m
,
MAPPING_ANNOTATION_METHOD
)
||
hasAnnotation
(
m
,
MAPPING_ANNOTATION_STATIC_METHOD
))
append
(
"()"
);
if
(
isUnmapped
())
{
line
(
unmappedDataInitializer
);
append
(
".setMapping("
);
writeMapping
(
m
,
ref
+
"_mapping"
,
true
);
line
(
")"
);
}
else
{
String
classQName
=
m
.
getDataResourceMapping
().
getResourceURI
();
append
(
classQName
+
"."
+
m
.
getElementURI
());
if
(
hasAnnotation
(
m
,
MAPPING_ANNOTATION_METHOD
)
||
hasAnnotation
(
m
,
MAPPING_ANNOTATION_STATIC_METHOD
))
append
(
"()"
);
}
}
}
else
if
(
dataType
!=
null
)
{
...
...
@@ -1559,17 +1786,26 @@ public class JUnitTestGenerator extends Renderer {
if
(
d
instanceof
DataElementUse
)
collectionItems
=
((
DataElementUse
)
d
).
getItem
();
}
DataElementMapping
m
=
getMapping
(
dataType
);
if
(
m
!=
null
)
{
if
(
hasAnnotation
(
m
,
MAPPING_ANNOTATION_CLASS
))
{
append
(
"new "
);
if
(
isCollection
)
append
(
"java.util.ArrayList<"
);
String
classQName
=
m
.
getDataResourceMapping
().
getResourceURI
();
append
(
classQName
+
"."
+
m
.
getElementURI
());
if
(
isCollection
)
append
(
">"
);
append
(
"()"
);
if
(
isUnmapped
())
{
append
(
unmappedDataInitializer
);
if
(
isCollection
)
line
(
".setIsCollection(true)"
);
else
line
(
".setIsStructure(true)"
);
}
else
{
DataElementMapping
m
=
getMapping
(
dataType
);
if
(
m
!=
null
)
{
if
(
hasAnnotation
(
m
,
MAPPING_ANNOTATION_CLASS
))
{
append
(
"new "
);
if
(
isCollection
)
append
(
"java.util.ArrayList<"
);
String
classQName
=
m
.
getDataResourceMapping
().
getResourceURI
();
append
(
classQName
+
"."
+
m
.
getElementURI
());
if
(
isCollection
)
append
(
">"
);
append
(
"()"
);
}
}
}
...
...
@@ -1577,6 +1813,8 @@ public class JUnitTestGenerator extends Renderer {
// XXX
}
else
if
(
d
instanceof
LiteralValueUse
)
{
if
(
isUnmapped
())
append
(
unmappedDataInitializer
+
".setValue("
);
String
str
=
((
LiteralValueUse
)
d
).
getValue
();
BigInteger
i
=
((
LiteralValueUse
)
d
).
getIntValue
();
Boolean
b
=
((
LiteralValueUse
)
d
).
getBoolValue
();
...
...
@@ -1586,8 +1824,12 @@ public class JUnitTestGenerator extends Renderer {
append
(
Integer
.
toString
(
i
.
intValue
()));
else
if
(
b
!=
null
)
append
(
Boolean
.
toString
(
b
));
if
(
isUnmapped
())
append
(
")"
);
}
else
if
(
function
!=
null
||
predefinedFunction
!=
null
)
{
if
(
isUnmapped
())
append
(
unmappedDataInitializer
+
".setValue("
);
if
(
function
!=
null
)
{
// TODO instance function
...
...
@@ -1619,13 +1861,21 @@ public class JUnitTestGenerator extends Renderer {
}
append
(
")"
);
if
(
isUnmapped
())
append
(
")"
);
}
else
if
(
formalParameter
!=
null
)
{
if
(
isUnmapped
())
append
(
unmappedDataInitializer
+
".setValue("
);
append
(
getElementName
(
formalParameter
));
if
(
isUnmapped
())
append
(
")"
);
}
else
if
(
d
instanceof
VariableUse
)
{
append
(
HELPER_FIELD
+
".clone("
+
getElementName
(((
VariableUse
)
d
).
getVariable
())
+
")"
);
}
line
(
";"
);
if
(!
getDataUseArguments
(
d
).
isEmpty
())
{
...
...
@@ -1648,27 +1898,39 @@ public class JUnitTestGenerator extends Renderer {
}
}
if
(
collectionItems
!=
null
)
{
for
(
DataUse
item:
collectionItems
)
{
for
(
DataUse
item
:
collectionItems
)
{
String
itemRef
=
dataUseVariables
.
get
(
item
);
append
(
ref
+
".add("
+
itemRef
+
")"
);
if
(
isUnmapped
())
append
(
ref
+
".addItem("
+
itemRef
+
".asData())"
);
else
append
(
ref
+
".add("
+
itemRef
+
")"
);
line
(
";"
);
}
}
}
private
void
writeMemberAssignment
(
Parameter
p
,
DataUse
v
,
Map
<
DataUse
,
String
>
dataUseVariables
)
{
ParameterMapping
mapping
=
getParameterMapping
(
p
);
if
(
hasAnnotation
(
mapping
,
MAPPING_ANNOTATION_SETTER
))
{
append
(
mapping
.
getParameterURI
());
if
(
isUnmapped
())
{
append
(
"setParameter"
);
append
(
"("
);
append
(
"\""
+
p
.
getName
()
+
"\", "
);
write
(
v
,
dataUseVariables
);
append
(
")"
);
}
else
{
append
(
mapping
.
getParameterURI
());
append
(
" = "
);
write
(
v
,
dataUseVariables
);
ParameterMapping
mapping
=
getParameterMapping
(
p
);
if
(
hasAnnotation
(
mapping
,
MAPPING_ANNOTATION_SETTER
))
{
append
(
mapping
.
getParameterURI
());
append
(
"("
);
write
(
v
,
dataUseVariables
);
append
(
")"
);
}
else
{
append
(
mapping
.
getParameterURI
());
append
(
" = "
);
write
(
v
,
dataUseVariables
);
}
}
}
...
...
@@ -1699,6 +1961,8 @@ public class JUnitTestGenerator extends Renderer {
}
else
{
append
(
dataUseVariables
.
get
(
d
));
if
(
isUnmapped
())
append
(
".asData()"
);
}
}
...
...
@@ -1753,13 +2017,18 @@ public class JUnitTestGenerator extends Renderer {
}
private
void
convertToData
(
DataUse
d
,
Map
<
DataUse
,
String
>
dataUseVariables
)
{
append
(
"new PojoData("
);
if
(!
isUnmapped
())
append
(
"new PojoData("
);
write
(
d
,
dataUseVariables
);
append
(
")"
);
if
(!
isUnmapped
())
append
(
")"
);
}
private
void
convertToArgument
(
String
parameterName
,
DataUse
d
,
Map
<
DataUse
,
String
>
dataUseVariables
)
{
append
(
"new PojoArgument("
);
if
(!
isUnmapped
())
append
(
"new PojoArgument("
);
else
append
(
"new Argument("
);
write
(
d
,
dataUseVariables
);
append
(
", \""
+
parameterName
+
"\""
);
append
(
")"
);
...
...
plugins/org.etsi.mts.tdl.execution.java/src/org/etsi/mts/tdl/execution/java/codegen/Renderer.java
View file @
f54d5b9f
...
...
@@ -13,6 +13,8 @@ import java.util.Hashtable;
import
java.util.Map
;
import
java.util.Set
;
import
javax.lang.model.SourceVersion
;
import
org.etsi.mts.tdl.DataElementMapping
;
import
org.etsi.mts.tdl.Element
;
import
org.etsi.mts.tdl.MappableDataElement
;
...
...
@@ -196,6 +198,8 @@ public abstract class Renderer {
private
String
getIdentifier
(
String
name
)
{
if
(
name
==
null
)
return
null
;
if
(
SourceVersion
.
isKeyword
(
name
))
name
=
name
+
"_"
;
char
[]
chars
=
name
.
toCharArray
();
for
(
int
i
=
0
;
i
<
chars
.
length
;
i
++)
{
if
(
i
==
0
)
{
...
...
plugins/org.etsi.mts.tdl.execution.java/src/org/etsi/mts/tdl/execution/java/codegen/Settings.java
View file @
f54d5b9f
...
...
@@ -6,20 +6,26 @@ public class Settings {
private
static
final
String
PREFIX
=
"JavaRendering."
;
public
static
final
String
OUTPUT_DIR
=
PREFIX
+
"OutputDir"
,
PACKAGE
=
PREFIX
+
"Package"
,
INJECTOR
=
PREFIX
+
"Injector"
,
DATE_FORMAT
=
PREFIX
+
"DateFormat"
;
INJECTOR
=
PREFIX
+
"Injector"
,
DATE_FORMAT
=
PREFIX
+
"DateFormat"
,
USE_MAPPING
=
PREFIX
+
"UseMapping"
,
UNMAPPED_DATA
=
PREFIX
+
"UnmappedData"
;
public
String
outputPath
;
public
File
outputFile
;
public
String
outPackage
;
public
String
injector
;
public
String
customDateFormat
;
public
String
useMapping
;
public
boolean
unmappedData
;
public
Settings
(
String
outputPath
,
File
outputFile
,
String
outPackage
,
String
injector
,
String
customDateFormat
)
{
public
Settings
(
String
outputPath
,
File
outputFile
,
String
outPackage
,
String
injector
,
String
customDateFormat
,
String
useMapping
,
boolean
unmappedData
)
{
this
.
outputPath
=
outputPath
;
this
.
outputFile
=
outputFile
;
this
.
outPackage
=
outPackage
;
this
.
injector
=
injector
;
this
.
customDateFormat
=
customDateFormat
;
this
.
useMapping
=
useMapping
;
this
.
unmappedData
=
unmappedData
;
}
}
plugins/org.etsi.mts.tdl.execution.java/src/org/etsi/mts/tdl/execution/java/eclipse/commands/RenderHandler.java
View file @
f54d5b9f
...
...
@@ -67,7 +67,9 @@ public class RenderHandler extends AbstractHandler implements IHandler {
generationDir
.
getLocation
().
toFile
(),
preferences
.
get
(
Settings
.
PACKAGE
,
""
),
preferences
.
get
(
Settings
.
INJECTOR
,
""
),
preferences
.
get
(
Settings
.
DATE_FORMAT
,
""
));
preferences
.
get
(
Settings
.
DATE_FORMAT
,
""
),
preferences
.
get
(
Settings
.
USE_MAPPING
,
""
),
preferences
.
getBoolean
(
Settings
.
UNMAPPED_DATA
,
false
));
JUnitTestGenerator
generator
=
new
JUnitTestGenerator
(
model
,
settings
);
...
...
plugins/org.etsi.mts.tdl.execution.java/src/org/etsi/mts/tdl/execution/java/eclipse/ui/PropertyPage.java
View file @
f54d5b9f
...
...
@@ -13,6 +13,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import
org.eclipse.core.runtime.IAdaptable
;
import
org.eclipse.core.runtime.IPath
;
import
org.eclipse.core.runtime.Path
;
import
org.eclipse.jface.preference.BooleanFieldEditor
;
import
org.eclipse.jface.preference.FieldEditor
;
import
org.eclipse.jface.preference.FieldEditorPreferencePage
;
import
org.eclipse.jface.preference.IPreferenceStore
;
...
...
@@ -81,7 +82,7 @@ public class PropertyPage extends FieldEditorPreferencePage implements IWorkbenc
FieldEditor
e
=
(
FieldEditor
)
event
.
getSource
();
String
name
=
e
.
getPreferenceName
();
String
value
=
(
String
)
event
.
getNewValue
();
String
value
=
event
.
getNewValue
()
.
toString
()
;
fields
.
put
(
e
,
value
);
...
...
@@ -121,6 +122,14 @@ public class PropertyPage extends FieldEditorPreferencePage implements IWorkbenc
StringFieldEditor
dateFormat
=
new
StringFieldEditor
(
Settings
.
DATE_FORMAT
,
"Date format"
,
parent
);
addField
(
dateFormat
);
parent
=
getFieldEditorParent
();
StringFieldEditor
useMapping
=
new
StringFieldEditor
(
Settings
.
USE_MAPPING
,
"Mapping for TRI"
,
parent
);
addField
(
useMapping
);
parent
=
getFieldEditorParent
();
BooleanFieldEditor
unmappedData
=
new
BooleanFieldEditor
(
Settings
.
UNMAPPED_DATA
,
"Use unmapped data"
,
parent
);
addField
(
unmappedData
);
}
private
boolean
isValid
(
FieldEditor
e
)
{
...
...