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
a772559e
Commit
a772559e
authored
Oct 11, 2019
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added test in one because we have only one mongDB. Need to create testcases
parent
3657f0f4
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
460 additions
and
42 deletions
+460
-42
CredentialApiController.java
...ain/java/nl/uva/sne/drip/api/CredentialApiController.java
+19
-17
ToscaTemplateApiController.java
.../java/nl/uva/sne/drip/api/ToscaTemplateApiController.java
+0
-3
CredentialDAO.java
...ager/src/main/java/nl/uva/sne/drip/dao/CredentialDAO.java
+19
-0
Credentials.java
...ager/src/main/java/nl/uva/sne/drip/model/Credentials.java
+21
-6
ToscaTemplate.java
...er/src/main/java/nl/uva/sne/drip/model/ToscaTemplate.java
+12
-12
CredentialService.java
.../main/java/nl/uva/sne/drip/service/CredentialService.java
+57
-0
MongoConfig.java
.../test/java/nl/uva/sne/drip/configuration/MongoConfig.java
+5
-4
ServiceTests.java
...r/src/test/java/nl/uva/sne/drip/service/ServiceTests.java
+327
-0
No files found.
drip-manager/src/main/java/nl/uva/sne/drip/api/CredentialApiController.java
View file @
a772559e
...
...
@@ -8,18 +8,14 @@ import org.slf4j.LoggerFactory;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestPart
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.validation.constraints.*
;
import
javax.validation.Valid
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.IOException
;
import
java.util.List
;
import
nl.uva.sne.drip.service.CredentialService
;
import
nl.uva.sne.drip.service.ToscaTemplateService
;
import
org.springframework.beans.factory.annotation.Autowired
;
@javax
.
annotation
.
Generated
(
value
=
"io.swagger.codegen.languages.SpringCodegen"
,
date
=
"2019-10-10T17:15:46.465Z"
)
...
...
@@ -32,29 +28,35 @@ public class CredentialApiController implements CredentialApi {
private
final
HttpServletRequest
request
;
@Autowired
private
CredentialService
credentialService
;
@org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
public
CredentialApiController
(
ObjectMapper
objectMapper
,
HttpServletRequest
request
)
{
this
.
objectMapper
=
objectMapper
;
this
.
request
=
request
;
}
public
ResponseEntity
<
String
>
createCredentials
(
@ApiParam
(
value
=
"Created user object"
,
required
=
true
)
@Valid
@RequestBody
Credentials
body
)
{
@Override
public
ResponseEntity
<
String
>
createCredentials
(
@ApiParam
(
value
=
"Created user object"
,
required
=
true
)
@Valid
@RequestBody
Credentials
body
)
{
String
accept
=
request
.
getHeader
(
"Accept"
);
if
(
accept
!=
null
&&
accept
.
contains
(
"application/json"
))
{
try
{
return
new
ResponseEntity
<
String
>(
objectMapper
.
readValue
(
"\"\""
,
String
.
class
),
HttpStatus
.
NOT_IMPLEMENTED
);
}
catch
(
IOException
e
)
{
log
.
error
(
"Couldn't serialize response for content type application/json"
,
e
);
return
new
ResponseEntity
<
String
>(
HttpStatus
.
INTERNAL_SERVER_ERROR
);
}
String
id
=
credentialService
.
save
(
body
);
return
new
ResponseEntity
<>(
id
,
HttpStatus
.
OK
);
}
return
new
ResponseEntity
<
String
>(
HttpStatus
.
NOT_IMPLEMENTED
);
return
new
ResponseEntity
<>(
HttpStatus
.
NOT_IMPLEMENTED
);
}
@Override
public
ResponseEntity
<
List
<
String
>>
getCredentialIDs
()
{
throw
new
UnsupportedOperationException
(
"Not supported yet."
);
//To change body of generated methods, choose Tools | Templates.
String
accept
=
request
.
getHeader
(
"Accept"
);
if
(
accept
!=
null
&&
accept
.
contains
(
"application/json"
))
{
List
<
String
>
ids
=
credentialService
.
getAllIds
();
return
new
ResponseEntity
<>(
ids
,
HttpStatus
.
OK
);
}
return
new
ResponseEntity
<>(
HttpStatus
.
NOT_IMPLEMENTED
);
}
}
drip-manager/src/main/java/nl/uva/sne/drip/api/ToscaTemplateApiController.java
View file @
a772559e
...
...
@@ -25,8 +25,6 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ToscaTemplateApiController
.
class
);
private
final
ObjectMapper
objectMapper
;
private
final
HttpServletRequest
request
;
@Autowired
...
...
@@ -34,7 +32,6 @@ public class ToscaTemplateApiController implements ToscaTemplateApi {
@org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
public
ToscaTemplateApiController
(
ObjectMapper
objectMapper
,
HttpServletRequest
request
)
{
this
.
objectMapper
=
objectMapper
;
this
.
request
=
request
;
}
...
...
drip-manager/src/main/java/nl/uva/sne/drip/dao/CredentialDAO.java
0 → 100644
View file @
a772559e
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
nl
.
uva
.
sne
.
drip
.
dao
;
import
nl.uva.sne.drip.model.Credentials
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.stereotype.Repository
;
/**
*
* @author S. Koulouzis
*/
@Repository
public
interface
CredentialDAO
extends
MongoRepository
<
Credentials
,
String
>
{
}
drip-manager/src/main/java/nl/uva/sne/drip/model/Credentials.java
View file @
a772559e
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
;
...
...
@@ -9,6 +10,7 @@ import java.util.HashMap;
import
java.util.Map
;
import
org.springframework.validation.annotation.Validated
;
import
javax.validation.Valid
;
import
org.springframework.data.annotation.Id
;
/**
* Credentials
...
...
@@ -17,6 +19,10 @@ import javax.validation.Valid;
@JsonInclude
(
Include
.
NON_NULL
)
public
class
Credentials
{
@Id
@JsonIgnore
private
String
id
;
@JsonProperty
(
"protocol"
)
private
String
protocol
=
null
;
...
...
@@ -41,11 +47,20 @@ public class Credentials {
return
this
;
}
@JsonIgnore
public
String
getId
()
{
return
id
;
}
public
void
setID
(
String
id
)
{
this
.
id
=
id
;
}
/**
* Get protocol
*
* @return protocol
*
*
*/
@ApiModelProperty
(
value
=
""
)
...
...
@@ -66,7 +81,7 @@ public class Credentials {
* Get tokenType
*
* @return tokenType
*
*
*/
@ApiModelProperty
(
value
=
""
)
...
...
@@ -87,7 +102,7 @@ public class Credentials {
* Get token
*
* @return token
*
*
*/
@ApiModelProperty
(
value
=
""
)
...
...
@@ -116,7 +131,7 @@ public class Credentials {
* Get keys
*
* @return keys
*
*
*/
@ApiModelProperty
(
value
=
""
)
...
...
@@ -137,7 +152,7 @@ public class Credentials {
* Get user
*
* @return user
*
*
*/
@ApiModelProperty
(
value
=
""
)
...
...
@@ -158,7 +173,7 @@ public class Credentials {
* Get cloudProviderName
*
* @return cloudProviderName
*
*
*/
@ApiModelProperty
(
value
=
""
)
...
...
drip-manager/src/main/java/nl/uva/sne/drip/model/ToscaTemplate.java
View file @
a772559e
...
...
@@ -170,7 +170,7 @@ public class ToscaTemplate {
public
ToscaTemplate
addImportsItem
(
Map
<
String
,
String
>
importsItem
)
{
if
(
this
.
imports
==
null
)
{
this
.
imports
=
new
ArrayList
<
Map
<
String
,
String
>
>();
this
.
imports
=
new
ArrayList
<>();
}
this
.
imports
.
add
(
importsItem
);
return
this
;
...
...
@@ -201,7 +201,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putRepositoriesItem
(
String
key
,
String
repositoriesItem
)
{
if
(
this
.
repositories
==
null
)
{
this
.
repositories
=
new
HashMap
<
String
,
String
>();
this
.
repositories
=
new
HashMap
<>();
}
this
.
repositories
.
put
(
key
,
repositoriesItem
);
return
this
;
...
...
@@ -230,7 +230,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putDslDefinitionsItem
(
String
key
,
String
dslDefinitionsItem
)
{
if
(
this
.
dslDefinitions
==
null
)
{
this
.
dslDefinitions
=
new
HashMap
<
String
,
String
>();
this
.
dslDefinitions
=
new
HashMap
<>();
}
this
.
dslDefinitions
.
put
(
key
,
dslDefinitionsItem
);
return
this
;
...
...
@@ -259,7 +259,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putNodeTypesItem
(
String
key
,
Object
nodeTypesItem
)
{
if
(
this
.
nodeTypes
==
null
)
{
this
.
nodeTypes
=
new
HashMap
<
String
,
Object
>();
this
.
nodeTypes
=
new
HashMap
<>();
}
this
.
nodeTypes
.
put
(
key
,
nodeTypesItem
);
return
this
;
...
...
@@ -311,7 +311,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putRelationshipTypesItem
(
String
key
,
Object
relationshipTypesItem
)
{
if
(
this
.
relationshipTypes
==
null
)
{
this
.
relationshipTypes
=
new
HashMap
<
String
,
Object
>();
this
.
relationshipTypes
=
new
HashMap
<>();
}
this
.
relationshipTypes
.
put
(
key
,
relationshipTypesItem
);
return
this
;
...
...
@@ -340,7 +340,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putRelationshipTemplatesItem
(
String
key
,
Object
relationshipTemplatesItem
)
{
if
(
this
.
relationshipTemplates
==
null
)
{
this
.
relationshipTemplates
=
new
HashMap
<
String
,
Object
>();
this
.
relationshipTemplates
=
new
HashMap
<>();
}
this
.
relationshipTemplates
.
put
(
key
,
relationshipTemplatesItem
);
return
this
;
...
...
@@ -369,7 +369,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putCapabilityTypesItem
(
String
key
,
Object
capabilityTypesItem
)
{
if
(
this
.
capabilityTypes
==
null
)
{
this
.
capabilityTypes
=
new
HashMap
<
String
,
Object
>();
this
.
capabilityTypes
=
new
HashMap
<>();
}
this
.
capabilityTypes
.
put
(
key
,
capabilityTypesItem
);
return
this
;
...
...
@@ -398,7 +398,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putArtifactTypesItem
(
String
key
,
Object
artifactTypesItem
)
{
if
(
this
.
artifactTypes
==
null
)
{
this
.
artifactTypes
=
new
HashMap
<
String
,
Object
>();
this
.
artifactTypes
=
new
HashMap
<>();
}
this
.
artifactTypes
.
put
(
key
,
artifactTypesItem
);
return
this
;
...
...
@@ -427,7 +427,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putDataTypesItem
(
String
key
,
Object
dataTypesItem
)
{
if
(
this
.
dataTypes
==
null
)
{
this
.
dataTypes
=
new
HashMap
<
String
,
Object
>();
this
.
dataTypes
=
new
HashMap
<>();
}
this
.
dataTypes
.
put
(
key
,
dataTypesItem
);
return
this
;
...
...
@@ -456,7 +456,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putInterfaceTypesItem
(
String
key
,
Object
interfaceTypesItem
)
{
if
(
this
.
interfaceTypes
==
null
)
{
this
.
interfaceTypes
=
new
HashMap
<
String
,
Object
>();
this
.
interfaceTypes
=
new
HashMap
<>();
}
this
.
interfaceTypes
.
put
(
key
,
interfaceTypesItem
);
return
this
;
...
...
@@ -485,7 +485,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putPolicyTypesItem
(
String
key
,
String
policyTypesItem
)
{
if
(
this
.
policyTypes
==
null
)
{
this
.
policyTypes
=
new
HashMap
<
String
,
String
>();
this
.
policyTypes
=
new
HashMap
<>();
}
this
.
policyTypes
.
put
(
key
,
policyTypesItem
);
return
this
;
...
...
@@ -514,7 +514,7 @@ public class ToscaTemplate {
public
ToscaTemplate
putGroupTypesItem
(
String
key
,
Object
groupTypesItem
)
{
if
(
this
.
groupTypes
==
null
)
{
this
.
groupTypes
=
new
HashMap
<
String
,
Object
>();
this
.
groupTypes
=
new
HashMap
<>();
}
this
.
groupTypes
.
put
(
key
,
groupTypesItem
);
return
this
;
...
...
drip-manager/src/main/java/nl/uva/sne/drip/service/CredentialService.java
0 → 100644
View file @
a772559e
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package
nl
.
uva
.
sne
.
drip
.
service
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
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.Feature
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
nl.uva.sne.drip.dao.CredentialDAO
;
import
nl.uva.sne.drip.model.Credentials
;
/**
*
* @author S. Koulouzis
*/
@Service
public
class
CredentialService
{
@Autowired
private
CredentialDAO
dao
;
public
String
save
(
Credentials
document
)
{
dao
.
save
(
document
);
return
document
.
getId
();
}
public
Credentials
findByID
(
String
id
)
throws
JsonProcessingException
{
Credentials
credentials
=
dao
.
findById
(
id
).
get
();
return
credentials
;
}
public
void
deleteByID
(
String
id
)
{
dao
.
deleteById
(
id
);
}
public
List
<
String
>
getAllIds
()
{
List
<
String
>
allIds
=
new
ArrayList
<>();
List
<
Credentials
>
all
=
dao
.
findAll
();
for
(
Credentials
tt
:
all
)
{
allIds
.
add
(
tt
.
getId
());
}
return
allIds
;
}
void
deleteAll
()
{
dao
.
deleteAll
();
}
}
drip-manager/src/test/java/nl/uva/sne/drip/configuration/MongoConfig.java
View file @
a772559e
...
...
@@ -16,6 +16,7 @@
package
nl
.
uva
.
sne
.
drip
.
configuration
;
import
com.mongodb.MongoClient
;
import
com.mongodb.MongoClientOptions
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.data.mongodb.config.AbstractMongoConfiguration
;
...
...
@@ -28,6 +29,9 @@ import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
@ComponentScan
(
basePackages
=
{
"nl.uva.sne.drip"
,
"nl.uva.sne.drip.api"
,
"nl.uva.sne.drip.configuration"
,
"nl.uva.sne.drip.dao"
,
"nl.uva.sne.drip.model"
,
"nl.uva.sne.drip.service"
})
public
class
MongoConfig
extends
AbstractMongoConfiguration
{
public
static
int
MONGO_TEST_PORT
=
12345
;
public
static
String
MONGO_TEST_HOST
=
"localhost"
;
@Override
protected
String
getDatabaseName
()
{
return
"test-db"
;
...
...
@@ -40,9 +44,6 @@ public class MongoConfig extends AbstractMongoConfiguration {
@Override
public
MongoClient
mongoClient
()
{
String
bindIp
=
"localhost"
;
int
port
=
12345
;
return
new
MongoClient
(
bindIp
,
port
);
return
new
MongoClient
(
MONGO_TEST_HOST
,
MONGO_TEST_PORT
);
}
}
drip-manager/src/test/java/nl/uva/sne/drip/service/
ToscaTemplateServiceTest
.java
→
drip-manager/src/test/java/nl/uva/sne/drip/service/
ServiceTests
.java
View file @
a772559e
This diff is collapsed.
Click to expand it.
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