Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
System
Partition
Commits
86aa2955
Commit
86aa2955
authored
Oct 01, 2020
by
neelesh thakur
Browse files
Merge branch 'master' into table-storage
parents
e31f79ac
cf959a19
Changes
6
Hide whitespace changes
Inline
Side-by-side
docs/api/partition_openapi.yaml
View file @
86aa2955
...
...
@@ -118,10 +118,6 @@ paths:
schema
:
$ref
:
'
#/definitions/PartitionInfo'
responses
:
'
200'
:
description
:
OK
schema
:
$ref
:
'
#/definitions/PartitionInfo'
'
201'
:
description
:
Created
'
401'
:
...
...
partition-core/src/main/java/org/opengroup/osdu/partition/api/PartitionApi.java
View file @
86aa2955
...
...
@@ -23,8 +23,10 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.context.annotation.RequestScope
;
import
org.springframework.web.servlet.support.ServletUriComponentsBuilder
;
import
javax.validation.Valid
;
import
java.net.URI
;
import
java.util.Map
;
@RestController
...
...
@@ -38,8 +40,10 @@ public class PartitionApi {
@PostMapping
(
"/{partitionId}"
)
@PreAuthorize
(
"@authorizationFilter.hasPermissions()"
)
public
ResponseEntity
<
PartitionInfo
>
create
(
@PathVariable
(
"partitionId"
)
String
partitionId
,
@RequestBody
@Valid
PartitionInfo
partitionInfo
)
{
return
ResponseEntity
.
ok
(
this
.
partitionService
.
createPartition
(
partitionId
,
partitionInfo
));
public
ResponseEntity
create
(
@PathVariable
(
"partitionId"
)
String
partitionId
,
@RequestBody
@Valid
PartitionInfo
partitionInfo
)
{
this
.
partitionService
.
createPartition
(
partitionId
,
partitionInfo
);
URI
partitionLocation
=
ServletUriComponentsBuilder
.
fromCurrentRequest
().
buildAndExpand
().
toUri
();
return
ResponseEntity
.
created
(
partitionLocation
).
build
();
}
@GetMapping
(
"/{partitionId}"
)
...
...
partition-core/src/test/java/org/opengroup/osdu/partition/api/PartitionApiTest.java
View file @
86aa2955
...
...
@@ -23,18 +23,27 @@ import org.opengroup.osdu.core.common.model.http.AppException;
import
org.opengroup.osdu.partition.model.PartitionInfo
;
import
org.opengroup.osdu.partition.model.Property
;
import
org.opengroup.osdu.partition.provider.interfaces.IPartitionService
;
import
org.powermock.core.classloader.annotations.PrepareForTest
;
import
org.powermock.modules.junit4.PowerMockRunner
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.mock.web.MockHttpServletRequest
;
import
org.springframework.web.servlet.support.ServletUriComponentsBuilder
;
import
javax.servlet.http.HttpServletRequest
;
import
java.net.URI
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyString
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
static
org
.
mockito
.
Mockito
.*;
import
static
org
.
powermock
.
api
.
mockito
.
PowerMockito
.
mockStatic
;
@RunWith
(
MockitoJUnitRunner
.
class
)
@RunWith
(
PowerMockRunner
.
class
)
@PrepareForTest
(
ServletUriComponentsBuilder
.
class
)
public
class
PartitionApiTest
{
private
final
AppException
NOT_FOUND_EXCEPTION
=
...
...
@@ -50,15 +59,22 @@ public class PartitionApiTest {
@Mock
private
PartitionInfo
partitionInfo
;
@Test
public
void
should_return201AndPartitionId_when_givenValidPartitionId
()
{
String
partitionId
=
"partition1"
;
when
(
partitionService
.
createPartition
(
anyString
(),
any
(
PartitionInfo
.
class
))).
thenReturn
(
partitionInfo
);
mockStatic
(
ServletUriComponentsBuilder
.
class
);
ResponseEntity
<
PartitionInfo
>
result
=
this
.
sut
.
create
(
partitionId
,
partitionInfo
);
assertEquals
(
HttpStatus
.
OK
,
result
.
getStatusCode
());
assertEquals
(
partitionInfo
,
result
.
getBody
());
ServletUriComponentsBuilder
builder
=
spy
(
ServletUriComponentsBuilder
.
class
);
when
(
ServletUriComponentsBuilder
.
fromCurrentRequest
()).
thenReturn
(
builder
);
ResponseEntity
result
=
this
.
sut
.
create
(
partitionId
,
partitionInfo
);
assertEquals
(
HttpStatus
.
CREATED
,
result
.
getStatusCode
());
assertNull
(
result
.
getBody
());
assertNotNull
(
result
.
getHeaders
().
get
(
HttpHeaders
.
LOCATION
));
}
@Test
...
...
testing/partition-test-core/src/main/java/org/opengroup/osdu/partition/api/CreatePartitionTest.java
View file @
86aa2955
...
...
@@ -49,7 +49,7 @@ public abstract class CreatePartitionTest extends BaseTestTemplate {
@Override
protected
int
expectedOkResponseCode
()
{
return
HttpStatus
.
OK
.
value
();
return
HttpStatus
.
CREATED
.
value
();
}
@Test
...
...
testing/partition-test-core/src/main/java/org/opengroup/osdu/partition/api/DeletePartitionTest.java
View file @
86aa2955
...
...
@@ -64,7 +64,7 @@ public abstract class DeletePartitionTest extends BaseTestTemplate {
ClientResponse
createResponse
=
this
.
descriptor
.
run
(
this
.
getId
(),
this
.
testUtils
.
getAccessToken
());
Assert
.
assertEquals
(
this
.
error
((
String
)
createResponse
.
getEntity
(
String
.
class
))
,
HttpStatus
.
OK
.
value
(),
(
long
)
createResponse
.
getStatus
());
,
HttpStatus
.
CREATED
.
value
(),
(
long
)
createResponse
.
getStatus
());
this
.
descriptor
=
oldDescriptor
;
}
...
...
testing/partition-test-core/src/main/java/org/opengroup/osdu/partition/api/GetPartitionByIdApitTest.java
View file @
86aa2955
...
...
@@ -47,7 +47,7 @@ public abstract class GetPartitionByIdApitTest extends BaseTestTemplate {
ClientResponse
createResponse
=
createPartitionDescriptor
.
run
(
this
.
getId
(),
this
.
testUtils
.
getAccessToken
());
assertEquals
(
this
.
error
((
String
)
createResponse
.
getEntity
(
String
.
class
))
,
HttpStatus
.
OK
.
value
(),
(
long
)
createResponse
.
getStatus
());
,
HttpStatus
.
CREATED
.
value
(),
(
long
)
createResponse
.
getStatus
());
}
public
GetPartitionByIdApitTest
()
{
...
...
Write
Preview
Supports
Markdown
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