Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
4053fc74
Commit
4053fc74
authored
Oct 25, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for utils
updated model
parent
779bc2e5
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
1118 additions
and
1127 deletions
+1118
-1127
NodeTemplateFactory.java
...va/nl/uva/sne/drip/commons/utils/NodeTemplateFactory.java
+34
-0
TOSCAUtils.java
...c/main/java/nl/uva/sne/drip/commons/utils/TOSCAUtils.java
+29
-173
Credentials.java
...mons/src/main/java/nl/uva/sne/drip/model/Credentials.java
+178
-199
NodeTemplate.java
...ons/src/main/java/nl/uva/sne/drip/model/NodeTemplate.java
+2
-3
TopologyTemplate.java
...src/main/java/nl/uva/sne/drip/model/TopologyTemplate.java
+9
-9
ToscaTemplate.java
...ns/src/main/java/nl/uva/sne/drip/model/ToscaTemplate.java
+507
-543
User.java
drip-commons/src/main/java/nl/uva/sne/drip/model/User.java
+190
-200
TOSCAUtilsTest.java
...st/java/nl/uva/sne/drip/commons/utils/TOSCAUtilsTest.java
+169
-0
No files found.
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/NodeTemplateFactory.java
0 → 100644
View file @
4053fc74
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
utils
;
import
java.util.Map
;
import
nl.uva.sne.drip.model.NodeTemplate
;
/**
*
* @author S. Koulouzis
*/
class
NodeTemplateFactory
{
static
NodeTemplate
create
(
Map
.
Entry
node
)
{
NodeTemplate
nodeTemplate
=
new
NodeTemplate
();
Map
<
String
,
Object
>
nodeMap
=
(
Map
<
String
,
Object
>)
node
.
getValue
();
nodeTemplate
.
setArtifacts
((
Map
<
String
,
Object
>)
nodeMap
.
get
(
"artifacts"
));
return
null
;
}
}
drip-commons/src/main/java/nl/uva/sne/drip/commons/utils/TOSCAUtils.java
View file @
4053fc74
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/model/Credentials.java
View file @
4053fc74
package
nl
.
uva
.
sne
.
drip
.
model
;
package
nl
.
uva
.
sne
.
drip
.
model
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonInclude.Include
;
import
java.util.Objects
;
import
java.util.Objects
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -10,19 +7,14 @@ import java.util.HashMap;
...
@@ -10,19 +7,14 @@ import java.util.HashMap;
import
java.util.Map
;
import
java.util.Map
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
org.springframework.data.annotation.Id
;
/**
/**
* Credentials
* Credentials
*/
*/
@Validated
@Validated
@JsonInclude
(
Include
.
NON_NULL
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.SpringCodegen"
,
date
=
"2019-10-25T14:09:25.182Z"
)
public
class
Credentials
{
@Id
@JsonIgnore
private
String
id
;
public
class
Credentials
{
@JsonProperty
(
"protocol"
)
@JsonProperty
(
"protocol"
)
private
String
protocol
=
null
;
private
String
protocol
=
null
;
...
@@ -47,23 +39,13 @@ public class Credentials {
...
@@ -47,23 +39,13 @@ public class Credentials {
return
this
;
return
this
;
}
}
@JsonIgnore
public
String
getId
()
{
return
id
;
}
public
void
setID
(
String
id
)
{
this
.
id
=
id
;
}
/**
/**
* Get protocol
* Get protocol
*
* @return protocol
* @return protocol
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getProtocol
()
{
public
String
getProtocol
()
{
return
protocol
;
return
protocol
;
}
}
...
@@ -79,12 +61,11 @@ public class Credentials {
...
@@ -79,12 +61,11 @@ public class Credentials {
/**
/**
* Get tokenType
* Get tokenType
*
* @return tokenType
* @return tokenType
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getTokenType
()
{
public
String
getTokenType
()
{
return
tokenType
;
return
tokenType
;
}
}
...
@@ -100,12 +81,11 @@ public class Credentials {
...
@@ -100,12 +81,11 @@ public class Credentials {
/**
/**
* Get token
* Get token
*
* @return token
* @return token
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getToken
()
{
public
String
getToken
()
{
return
token
;
return
token
;
}
}
...
@@ -129,12 +109,11 @@ public class Credentials {
...
@@ -129,12 +109,11 @@ public class Credentials {
/**
/**
* Get keys
* Get keys
*
* @return keys
* @return keys
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
Map
<
String
,
String
>
getKeys
()
{
public
Map
<
String
,
String
>
getKeys
()
{
return
keys
;
return
keys
;
}
}
...
@@ -150,12 +129,11 @@ public class Credentials {
...
@@ -150,12 +129,11 @@ public class Credentials {
/**
/**
* Get user
* Get user
*
* @return user
* @return user
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getUser
()
{
public
String
getUser
()
{
return
user
;
return
user
;
}
}
...
@@ -171,12 +149,11 @@ public class Credentials {
...
@@ -171,12 +149,11 @@ public class Credentials {
/**
/**
* Get cloudProviderName
* Get cloudProviderName
*
* @return cloudProviderName
* @return cloudProviderName
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getCloudProviderName
()
{
public
String
getCloudProviderName
()
{
return
cloudProviderName
;
return
cloudProviderName
;
}
}
...
@@ -185,6 +162,7 @@ public class Credentials {
...
@@ -185,6 +162,7 @@ public class Credentials {
this
.
cloudProviderName
=
cloudProviderName
;
this
.
cloudProviderName
=
cloudProviderName
;
}
}
@Override
@Override
public
boolean
equals
(
java
.
lang
.
Object
o
)
{
public
boolean
equals
(
java
.
lang
.
Object
o
)
{
if
(
this
==
o
)
{
if
(
this
==
o
)
{
...
@@ -194,12 +172,12 @@ public class Credentials {
...
@@ -194,12 +172,12 @@ public class Credentials {
return
false
;
return
false
;
}
}
Credentials
credentials
=
(
Credentials
)
o
;
Credentials
credentials
=
(
Credentials
)
o
;
return
Objects
.
equals
(
this
.
protocol
,
credentials
.
protocol
)
return
Objects
.
equals
(
this
.
protocol
,
credentials
.
protocol
)
&&
&&
Objects
.
equals
(
this
.
tokenType
,
credentials
.
tokenType
)
Objects
.
equals
(
this
.
tokenType
,
credentials
.
tokenType
)
&&
&&
Objects
.
equals
(
this
.
token
,
credentials
.
token
)
Objects
.
equals
(
this
.
token
,
credentials
.
token
)
&&
&&
Objects
.
equals
(
this
.
keys
,
credentials
.
keys
)
Objects
.
equals
(
this
.
keys
,
credentials
.
keys
)
&&
&&
Objects
.
equals
(
this
.
user
,
credentials
.
user
)
Objects
.
equals
(
this
.
user
,
credentials
.
user
)
&&
&&
Objects
.
equals
(
this
.
cloudProviderName
,
credentials
.
cloudProviderName
);
Objects
.
equals
(
this
.
cloudProviderName
,
credentials
.
cloudProviderName
);
}
}
@Override
@Override
...
@@ -233,3 +211,4 @@ public class Credentials {
...
@@ -233,3 +211,4 @@ public class Credentials {
return
o
.
toString
().
replace
(
"\n"
,
"\n "
);
return
o
.
toString
().
replace
(
"\n"
,
"\n "
);
}
}
}
}
drip-commons/src/main/java/nl/uva/sne/drip/model/NodeTemplate.java
View file @
4053fc74
package
nl
.
uva
.
sne
.
drip
.
model
;
package
nl
.
uva
.
sne
.
drip
.
model
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonInclude.Include
;
import
java.util.Objects
;
import
java.util.Objects
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -16,7 +14,8 @@ import javax.validation.Valid;
...
@@ -16,7 +14,8 @@ import javax.validation.Valid;
* NodeTemplate
* NodeTemplate
*/
*/
@Validated
@Validated
@JsonInclude
(
Include
.
NON_NULL
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.SpringCodegen"
,
date
=
"2019-10-25T14:09:25.182Z"
)
public
class
NodeTemplate
{
public
class
NodeTemplate
{
@JsonProperty
(
"name"
)
@JsonProperty
(
"name"
)
private
String
name
=
null
;
private
String
name
=
null
;
...
...
drip-commons/src/main/java/nl/uva/sne/drip/model/TopologyTemplate.java
View file @
4053fc74
package
nl
.
uva
.
sne
.
drip
.
model
;
package
nl
.
uva
.
sne
.
drip
.
model
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonInclude.Include
;
import
java.util.Objects
;
import
java.util.Objects
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
...
@@ -16,7 +14,8 @@ import javax.validation.Valid;
...
@@ -16,7 +14,8 @@ import javax.validation.Valid;
* TopologyTemplate
* TopologyTemplate
*/
*/
@Validated
@Validated
@JsonInclude
(
Include
.
NON_NULL
)
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.SpringCodegen"
,
date
=
"2019-10-25T14:47:27.096Z"
)
public
class
TopologyTemplate
{
public
class
TopologyTemplate
{
@JsonProperty
(
"description"
)
@JsonProperty
(
"description"
)
private
String
description
=
null
;
private
String
description
=
null
;
...
@@ -35,7 +34,7 @@ public class TopologyTemplate {
...
@@ -35,7 +34,7 @@ public class TopologyTemplate {
@JsonProperty
(
"node_templates"
)
@JsonProperty
(
"node_templates"
)
@Valid
@Valid
private
Map
<
String
,
Object
>
nodeTemplates
=
null
;
private
Map
<
String
,
NodeTemplate
>
nodeTemplates
=
null
;
@JsonProperty
(
"relationship_templates"
)
@JsonProperty
(
"relationship_templates"
)
@Valid
@Valid
...
@@ -156,14 +155,14 @@ public class TopologyTemplate {
...
@@ -156,14 +155,14 @@ public class TopologyTemplate {
this
.
outputs
=
outputs
;
this
.
outputs
=
outputs
;
}
}
public
TopologyTemplate
nodeTemplates
(
Map
<
String
,
Object
>
nodeTemplates
)
{
public
TopologyTemplate
nodeTemplates
(
Map
<
String
,
NodeTemplate
>
nodeTemplates
)
{
this
.
nodeTemplates
=
nodeTemplates
;
this
.
nodeTemplates
=
nodeTemplates
;
return
this
;
return
this
;
}
}
public
TopologyTemplate
putNodeTemplatesItem
(
String
key
,
Object
nodeTemplatesItem
)
{
public
TopologyTemplate
putNodeTemplatesItem
(
String
key
,
NodeTemplate
nodeTemplatesItem
)
{
if
(
this
.
nodeTemplates
==
null
)
{
if
(
this
.
nodeTemplates
==
null
)
{
this
.
nodeTemplates
=
new
HashMap
<
String
,
Object
>();
this
.
nodeTemplates
=
new
HashMap
<
String
,
NodeTemplate
>();
}
}
this
.
nodeTemplates
.
put
(
key
,
nodeTemplatesItem
);
this
.
nodeTemplates
.
put
(
key
,
nodeTemplatesItem
);
return
this
;
return
this
;
...
@@ -175,12 +174,13 @@ public class TopologyTemplate {
...
@@ -175,12 +174,13 @@ public class TopologyTemplate {
**/
**/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
@Valid
public
Map
<
String
,
Object
>
getNodeTemplates
()
{
public
Map
<
String
,
NodeTemplate
>
getNodeTemplates
()
{
return
nodeTemplates
;
return
nodeTemplates
;
}
}
public
void
setNodeTemplates
(
Map
<
String
,
Object
>
nodeTemplates
)
{
public
void
setNodeTemplates
(
Map
<
String
,
NodeTemplate
>
nodeTemplates
)
{
this
.
nodeTemplates
=
nodeTemplates
;
this
.
nodeTemplates
=
nodeTemplates
;
}
}
...
...
drip-commons/src/main/java/nl/uva/sne/drip/model/ToscaTemplate.java
View file @
4053fc74
This diff is collapsed.
Click to expand it.
drip-commons/src/main/java/nl/uva/sne/drip/model/User.java
View file @
4053fc74
...
@@ -2,22 +2,17 @@ package nl.uva.sne.drip.model;
...
@@ -2,22 +2,17 @@ package nl.uva.sne.drip.model;
import
java.util.Objects
;
import
java.util.Objects
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonCreator
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.validation.annotation.Validated
;
import
javax.validation.Valid
;
import
javax.validation.constraints.*
;
import
org.springframework.data.annotation.Id
;
/**
/**
* User
* User
*/
*/
@Validated
@Validated
public
class
User
{
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.SpringCodegen"
,
date
=
"2019-10-25T14:09:25.182Z"
)
public
class
User
{
@JsonProperty
(
"id"
)
@JsonProperty
(
"id"
)
@Id
private
Long
id
=
null
;
private
Long
id
=
null
;
@JsonProperty
(
"username"
)
@JsonProperty
(
"username"
)
...
@@ -45,12 +40,11 @@ public class User {
...
@@ -45,12 +40,11 @@ public class User {
/**
/**
* Get id
* Get id
*
* @return id
* @return id
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
Long
getId
()
{
public
Long
getId
()
{
return
id
;
return
id
;
}
}
...
@@ -66,12 +60,11 @@ public class User {
...
@@ -66,12 +60,11 @@ public class User {
/**
/**
* Get username
* Get username
*
* @return username
* @return username
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getUsername
()
{
public
String
getUsername
()
{
return
username
;
return
username
;
}
}
...
@@ -87,12 +80,11 @@ public class User {
...
@@ -87,12 +80,11 @@ public class User {
/**
/**
* Get firstName
* Get firstName
*
* @return firstName
* @return firstName
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getFirstName
()
{
public
String
getFirstName
()
{
return
firstName
;
return
firstName
;
}
}
...
@@ -108,12 +100,11 @@ public class User {
...
@@ -108,12 +100,11 @@ public class User {
/**
/**
* Get lastName
* Get lastName
*
* @return lastName
* @return lastName
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getLastName
()
{
public
String
getLastName
()
{
return
lastName
;
return
lastName
;
}
}
...
@@ -129,12 +120,11 @@ public class User {
...
@@ -129,12 +120,11 @@ public class User {
/**
/**
* Get email
* Get email
*
* @return email
* @return email
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getEmail
()
{
public
String
getEmail
()
{
return
email
;
return
email
;
}
}
...
@@ -150,12 +140,11 @@ public class User {
...
@@ -150,12 +140,11 @@ public class User {
/**
/**
* Get password
* Get password
*
* @return password
* @return password
*
**/
*/
@ApiModelProperty
(
value
=
""
)
@ApiModelProperty
(
value
=
""
)
public
String
getPassword
()
{
public
String
getPassword
()
{
return
password
;
return
password
;
}
}
...
@@ -171,12 +160,11 @@ public class User {
...
@@ -171,12 +160,11 @@ public class User {
/**
/**
* User Status
* User Status
*
* @return userStatus
* @return userStatus
*
**/
*/
@ApiModelProperty
(
value
=
"User Status"
)
@ApiModelProperty
(
value
=
"User Status"
)
public
Integer
getUserStatus
()
{
public
Integer
getUserStatus
()
{
return
userStatus
;
return
userStatus
;
}
}
...
@@ -185,6 +173,7 @@ public class User {
...
@@ -185,6 +173,7 @@ public class User {
this
.
userStatus
=
userStatus
;
this
.
userStatus
=
userStatus
;
}
}
@Override
@Override
public
boolean
equals
(
java
.
lang
.
Object
o
)
{
public
boolean
equals
(
java
.
lang
.
Object
o
)
{
if
(
this
==
o
)
{
if
(
this
==
o
)
{
...
@@ -194,13 +183,13 @@ public class User {
...
@@ -194,13 +183,13 @@ public class User {
return
false
;
return
false
;
}
}
User
user
=
(
User
)
o
;
User
user
=
(
User
)
o
;
return
Objects
.
equals
(
this
.
id
,
user
.
id
)
return
Objects
.
equals
(
this
.
id
,
user
.
id
)
&&
&&
Objects
.
equals
(
this
.
username
,
user
.
username
)
Objects
.
equals
(
this
.
username
,
user
.
username
)
&&
&&
Objects
.
equals
(
this
.
firstName
,
user
.
firstName
)
Objects
.
equals
(
this
.
firstName
,
user
.
firstName
)
&&
&&
Objects
.
equals
(
this
.
lastName
,
user
.
lastName
)
Objects
.
equals
(
this
.
lastName
,
user
.
lastName
)
&&
&&
Objects
.
equals
(
this
.
email
,
user
.
email
)
Objects
.
equals
(
this
.
email
,
user
.
email
)
&&
&&
Objects
.
equals
(
this
.
password
,
user
.
password
)
Objects
.
equals
(
this
.
password
,
user
.
password
)
&&
&&
Objects
.
equals
(
this
.
userStatus
,
user
.
userStatus
);
Objects
.
equals
(
this
.
userStatus
,
user
.
userStatus
);
}
}
@Override
@Override
...
@@ -235,3 +224,4 @@ public class User {
...
@@ -235,3 +224,4 @@ public class User {
return
o
.
toString
().
replace
(
"\n"
,
"\n "
);
return
o
.
toString
().
replace
(
"\n"
,
"\n "
);
}
}
}
}
drip-commons/src/test/java/nl/uva/sne/drip/commons/utils/TOSCAUtilsTest.java
0 → 100644
View file @
4053fc74
/*
* Copyright 2017 S. Koulouzis, Wang Junchao, Huan Zhou, Yang Hu
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
nl
.
uva
.
sne
.
drip
.
commons
.
utils
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLFactory
;
import
com.fasterxml.jackson.dataformat.yaml.YAMLGenerator
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
nl.uva.sne.drip.model.NodeTemplate
;
import
nl.uva.sne.drip.model.ToscaTemplate
;
import
org.junit.After
;
import
org.junit.AfterClass
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
static
org
.
junit
.
Assert
.*;
/**
*
* @author alogo
*/
public
class
TOSCAUtilsTest
{
private
static
ToscaTemplate
toscaTemplate
;
public
TOSCAUtilsTest
()
{
}
@BeforeClass
public
static
void
setUpClass
()
throws
IOException
{
String
toscaFilePath
=
"../TOSCA/application_example_output.yaml"
;
String
ymlStr
=
new
String
(
Files
.
readAllBytes
(
Paths
.
get
(
toscaFilePath
)));
ObjectMapper
objectMapper
=
new
ObjectMapper
(
new
YAMLFactory
().
disable
(
YAMLGenerator
.
Feature
.
WRITE_DOC_START_MARKER
));
objectMapper
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
toscaTemplate
=
objectMapper
.
readValue
(
ymlStr
,
ToscaTemplate
.
class
);
}
@AfterClass
public
static
void
tearDownClass
()
{
}
@Before
public
void
setUp
()
{
}
@After
public
void
tearDown
()
{
}
/**
* Test of getNodesByType method, of class TOSCAUtils.
*/
@Test
public
void
testGetNodesByType
()
{
System
.
out
.
println
(
"getNodesByType"
);
String
nodeTypeName
=
"tosca.nodes.ARTICONF.VM.topology"
;
List
<
Map
<
String
,
NodeTemplate
>>
result
=
testGetNodesByType
(
nodeTypeName
);
assertEquals
(
1
,
result
.
size
());
nodeTypeName
=
"tosca.nodes.ARTICONF.VM.Compute"
;
result
=
testGetNodesByType
(
nodeTypeName
);
assertEquals
(
2
,
result
.
size
());
}
/**
* Test of getRelatedNodes method, of class TOSCAUtils.
*/
@Test
public
void
testGetRelatedNodes
()
{
System
.
out
.
println
(
"getRelatedNodes"
);
String
nodeTypeName
=
"tosca.nodes.ARTICONF.VM.topology"
;
List
<
Map
<
String
,
NodeTemplate
>>
vmTopologies
=
TOSCAUtils
.
getNodesByType
(
toscaTemplate
,
nodeTypeName
);
NodeTemplate
vmTopology
=
vmTopologies
.
get
(
0
).
get
(
vmTopologies
.
get
(
0
).
keySet
().
iterator
().
next
());
nodeTypeName
=
"tosca.nodes.ARTICONF.VM.Compute"
;
List
<
Map
<
String
,
NodeTemplate
>>
result
=
TOSCAUtils
.
getRelatedNodes
(
vmTopology
,
toscaTemplate
);
assertEquals
(
2
,
result
.
size
());
for
(
Map
<
String
,
NodeTemplate
>
node
:
result
)
{
String
name
=
node
.
keySet
().
iterator
().
next
();
assertEquals
(
nodeTypeName
,
node
.
get
(
name
).
getType
());
}
}
/**
* Test of nodeIsOfType method, of class TOSCAUtils.
*/
@Test
public
void
testNodeIsOfType
()
{
System
.
out
.
println
(
"nodeIsOfType"
);
String
nodeTypeName
=
"tosca.nodes.ARTICONF.VM.topology"
;
List
<
Map
<
String
,
NodeTemplate
>>
vmTopologies
=
TOSCAUtils
.
getNodesByType
(
toscaTemplate
,
nodeTypeName
);
NodeTemplate
vmTopology
=
vmTopologies
.
get
(
0
).
get
(
vmTopologies
.
get
(
0
).
keySet
().
iterator
().
next
());
boolean
expResult
=
true
;
boolean
result
=
TOSCAUtils
.
nodeIsOfType
(
vmTopology
,
nodeTypeName
);
assertEquals
(
expResult
,
result
);
expResult
=
false
;
nodeTypeName
=
"tosca.nodes.ARTICONF"
;
result
=
TOSCAUtils
.
nodeIsOfType
(
vmTopology
,
nodeTypeName
);
assertEquals
(
expResult
,
result
);
}
/**
* Test of getNodeProperty method, of class TOSCAUtils.
*/
@Test
public
void
testGetNodeProperty
()
{
System
.
out
.
println
(
"getNodeProperty"
);
testGetVMProperties
();
}
private
void
testGetVMProperties
()
{
String
nodeTypeName
=
"tosca.nodes.ARTICONF.VM.Compute"
;
List
<
Map
<
String
,
NodeTemplate
>>
vms
=
TOSCAUtils
.
getNodesByType
(
toscaTemplate
,
nodeTypeName
);
assertEquals
(
2
,
vms
.
size
());
Map
<
String
,
Object
>
vmProertyMap
=
new
HashMap
<>();
vmProertyMap
.
put
(
"disk_size"
,
"50000 MB"
);
vmProertyMap
.
put
(
"host_name"
,
"vm"
);
vmProertyMap
.
put
(
"mem_size"
,
"6000 MB"
);
vmProertyMap
.
put
(
"num_cores"
,
2
);
vmProertyMap
.
put
(
"os"
,
"ubuntu 16"
);
vmProertyMap
.
put
(
"user_name"
,
"vm_user"
);
for
(
Map
<
String
,
NodeTemplate
>
vmMap
:
vms
)
{
Set
<
String
>
keys
=
vmProertyMap
.
keySet
();
NodeTemplate
vm
=
vmMap
.
get
(
vmMap
.
keySet
().
iterator
().
next
());
for
(
String
propName
:
keys
)
{
Object
result
=
TOSCAUtils
.
getNodeProperty
(
vm
,
propName
);
assertEquals
(
vmProertyMap
.
get
(
propName
),
result
);
}
}
}
private
List
<
Map
<
String
,
NodeTemplate
>>
testGetNodesByType
(
String
nodeTypeName
)
{
List
<
Map
<
String
,
NodeTemplate
>>
result
=
TOSCAUtils
.
getNodesByType
(
toscaTemplate
,
nodeTypeName
);
for
(
Map
<
String
,
NodeTemplate
>
node
:
result
)
{
String
name
=
node
.
keySet
().
iterator
().
next
();
assertEquals
(
nodeTypeName
,
node
.
get
(
name
).
getType
());
}
return
result
;
}
}
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