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
36f300d3
Commit
36f300d3
authored
Sep 29, 2020
by
neelesh thakur
Browse files
clean-up
parent
0243115c
Pipeline
#10435
passed with stages
in 13 minutes and 46 seconds
Changes
12
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
partition-core/src/main/java/org/opengroup/osdu/partition/model/Property.java
View file @
36f300d3
// Copyright 2017-2020, Schlumberger
//
// 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
org.opengroup.osdu.partition.model
;
import
lombok.AllArgsConstructor
;
...
...
partition-core/src/test/java/org/opengroup/osdu/partition/api/PartitionApiTest.java
View file @
36f300d3
...
...
@@ -26,9 +26,7 @@ import org.opengroup.osdu.partition.provider.interfaces.IPartitionService;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
...
...
provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/di/CloudTableConfiguration.java
View file @
36f300d3
// Copyright 2017-2020, Schlumberger
//
// 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
org.opengroup.osdu.partition.provider.azure.di
;
import
lombok.Getter
;
...
...
provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/di/TableStorageClient.java
View file @
36f300d3
// Copyright 2017-2020, Schlumberger
//
// 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
org.opengroup.osdu.partition.provider.azure.di
;
import
com.microsoft.azure.storage.CloudStorageAccount
;
...
...
@@ -18,7 +32,7 @@ import java.security.InvalidKeyException;
@Component
public
class
TableStorageClient
{
private
final
String
CONNECTION_STRING
=
"DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=core.windows.net"
;
private
final
static
String
CONNECTION_STRING
=
"DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;EndpointSuffix=core.windows.net"
;
@Bean
@Lazy
...
...
provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/persistence/CloudTableStore.java
View file @
36f300d3
// Copyright 2017-2020, Schlumberger
//
// 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
org.opengroup.osdu.partition.provider.azure.persistence
;
import
com.microsoft.azure.storage.StorageException
;
...
...
@@ -42,7 +56,6 @@ public class CloudTableStore {
public
Iterable
<?
extends
TableEntity
>
queryByCompoundKey
(
final
Class
<?
extends
TableEntity
>
clazzType
,
final
String
rowKey
,
final
String
rowValue
,
final
String
valueKey
,
final
String
value
)
{
String
rowFilter
=
TableQuery
.
generateFilterCondition
(
rowKey
,
TableQuery
.
QueryComparisons
.
EQUAL
,
...
...
@@ -66,7 +79,7 @@ public class CloudTableStore {
try
{
this
.
cloudTableClient
.
execute
(
batchOperation
);
}
catch
(
StorageException
e
)
{
new
AppException
(
HttpStatus
.
SC_INTERNAL_SERVER_ERROR
,
"error creating partition"
,
e
.
getMessage
(),
e
);
throw
new
AppException
(
HttpStatus
.
SC_INTERNAL_SERVER_ERROR
,
"error creating partition"
,
e
.
getMessage
(),
e
);
}
}
}
provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/persistence/PartitionEntity.java
View file @
36f300d3
// Copyright 2017-2020, Schlumberger
//
// 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
org.opengroup.osdu.partition.provider.azure.persistence
;
import
com.microsoft.azure.storage.table.DynamicTableEntity
;
...
...
provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/persistence/PartitionTableStore.java
View file @
36f300d3
// Copyright 2017-2020, Schlumberger
//
// 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
org.opengroup.osdu.partition.provider.azure.persistence
;
import
com.microsoft.azure.storage.table.EntityProperty
;
...
...
@@ -19,8 +33,8 @@ public class PartitionTableStore {
private
final
static
String
VALUE
=
"value"
;
private
final
static
String
SENSITIVE
=
"sensitive"
;
private
final
String
PARTITION_KEY
=
"PartitionKey"
;
private
final
String
ROW_KEY
=
"RowKey"
;
private
final
static
String
PARTITION_KEY
=
"PartitionKey"
;
private
final
static
String
ROW_KEY
=
"RowKey"
;
@Autowired
private
CloudTableStore
cloudTableStore
;
...
...
@@ -76,17 +90,21 @@ public class PartitionTableStore {
return
out
;
}
@SuppressWarnings
(
"unchecked"
)
public
void
deletePartition
(
String
partitionId
)
{
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByKey
(
PartitionEntity
.
class
,
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByKey
(
PartitionEntity
.
class
,
PARTITION_KEY
,
partitionId
);
for
(
PartitionEntity
tableEntity
:
results
)
{
this
.
cloudTableStore
.
deleteCloudTableEntity
(
PartitionEntity
.
class
,
tableEntity
.
getPartitionKey
(),
tableEntity
.
getRowKey
());
}
}
@SuppressWarnings
(
"unchecked"
)
private
List
<
PartitionEntity
>
queryById
(
String
partitionId
)
{
List
<
PartitionEntity
>
out
=
new
ArrayList
<>();
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByCompoundKey
(
PartitionEntity
.
class
,
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByCompoundKey
(
PartitionEntity
.
class
,
ROW_KEY
,
ID
,
VALUE
,
partitionId
);
for
(
PartitionEntity
tableEntity
:
results
)
{
...
...
@@ -95,9 +113,11 @@ public class PartitionTableStore {
return
out
;
}
@SuppressWarnings
(
"unchecked"
)
private
List
<
PartitionEntity
>
getAllByPartitionId
(
String
partitionId
)
{
List
<
PartitionEntity
>
out
=
new
ArrayList
<>();
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByKey
(
PartitionEntity
.
class
,
Iterable
<
PartitionEntity
>
results
=
(
Iterable
<
PartitionEntity
>)
this
.
cloudTableStore
.
queryByKey
(
PartitionEntity
.
class
,
PARTITION_KEY
,
partitionId
);
for
(
PartitionEntity
tableEntity
:
results
)
{
tableEntity
.
setPartitionId
(
tableEntity
.
getPartitionKey
());
...
...
provider/partition-azure/src/main/java/org/opengroup/osdu/partition/provider/azure/utils/AuthorizationService.java
View file @
36f300d3
...
...
@@ -51,7 +51,7 @@ public class AuthorizationService implements IAuthorizationService {
*
* @return user principal
*/
private
final
Object
getUserPrincipal
()
{
private
Object
getUserPrincipal
()
{
final
Authentication
auth
=
SecurityContextHolder
.
getContext
().
getAuthentication
();
return
auth
.
getPrincipal
();
}
...
...
provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/PartitionApplicationTest.java
View file @
36f300d3
...
...
@@ -16,13 +16,12 @@ package org.opengroup.osdu.partition.provider.azure;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
javax.inject.Inject
;
import
static
org
.
junit
.
Assert
.
*
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
@RunWith
(
SpringRunner
.
class
)
public
class
PartitionApplicationTest
{
...
...
provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/di/AzureBootstrapConfigTest.java
View file @
36f300d3
...
...
@@ -24,9 +24,9 @@ import static org.mockito.Mockito.mock;
public
class
AzureBootstrapConfigTest
{
private
AzureBootstrapConfig
bootstrapConfig
=
new
AzureBootstrapConfig
();
private
final
AzureBootstrapConfig
bootstrapConfig
=
new
AzureBootstrapConfig
();
private
SecretClient
kv
=
mock
(
SecretClient
.
class
);
private
final
SecretClient
kv
=
mock
(
SecretClient
.
class
);
@Test
public
void
config_returnsCorrectSecret_tblStorage
()
{
...
...
provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/service/PartitionServiceImplTest.java
View file @
36f300d3
...
...
@@ -40,10 +40,10 @@ public class PartitionServiceImplTest {
@InjectMocks
private
PartitionServiceImpl
sut
;
private
PartitionInfo
partitionInfo
=
new
PartitionInfo
();
private
final
PartitionInfo
partitionInfo
=
new
PartitionInfo
();
private
final
static
String
PARTITION_ID
=
"my-tenant"
;
private
Map
<
String
,
Property
>
properties
=
new
HashMap
<>();
private
final
Map
<
String
,
Property
>
properties
=
new
HashMap
<>();
@Before
public
void
setup
()
{
...
...
@@ -60,7 +60,7 @@ public class PartitionServiceImplTest {
try
{
sut
.
createPartition
(
PARTITION_ID
,
this
.
partitionInfo
);
}
catch
(
AppException
e
)
{
assert
True
(
e
.
getError
().
getCode
()
==
409
);
assert
Equals
(
409
,
e
.
getError
().
getCode
());
assertTrue
(
e
.
getError
().
getReason
().
equalsIgnoreCase
(
"partition exist"
));
assertTrue
(
e
.
getError
().
getMessage
().
equalsIgnoreCase
(
"Partition with same id exist"
));
}
...
...
@@ -71,7 +71,7 @@ public class PartitionServiceImplTest {
when
(
this
.
tableStore
.
partitionExists
(
PARTITION_ID
)).
thenReturn
(
false
);
PartitionInfo
partInfo
=
sut
.
createPartition
(
PARTITION_ID
,
this
.
partitionInfo
);
assert
True
(
partInfo
.
getProperties
().
size
()
==
3
);
assert
Equals
(
3
,
partInfo
.
getProperties
().
size
());
assertTrue
(
partInfo
.
getProperties
().
containsKey
(
"id"
));
assertTrue
(
partInfo
.
getProperties
().
containsKey
(
"complianceRuleSet"
));
assertTrue
(
partInfo
.
getProperties
().
containsKey
(
"storageAccount"
));
...
...
@@ -94,7 +94,7 @@ public class PartitionServiceImplTest {
try
{
sut
.
getPartition
(
PARTITION_ID
);
}
catch
(
AppException
e
)
{
assert
True
(
e
.
getError
().
getCode
()
==
404
);
assert
Equals
(
404
,
e
.
getError
().
getCode
());
assertTrue
(
e
.
getError
().
getReason
().
equalsIgnoreCase
(
"partition not found"
));
assertTrue
(
e
.
getError
().
getMessage
().
equalsIgnoreCase
(
"my-tenant partition not found"
));
}
...
...
@@ -114,7 +114,7 @@ public class PartitionServiceImplTest {
try
{
this
.
sut
.
deletePartition
(
"test-partition"
);
}
catch
(
AppException
ae
)
{
assert
True
(
ae
.
getError
().
getCode
()
==
404
);
assert
Equals
(
404
,
ae
.
getError
().
getCode
());
assertEquals
(
"test-partition partition not found"
,
ae
.
getError
().
getMessage
());
}
}
...
...
provider/partition-azure/src/test/java/org/opengroup/osdu/partition/provider/azure/utils/AuthorizationServiceTest.java
View file @
36f300d3
...
...
@@ -25,7 +25,6 @@ import io.jsonwebtoken.Jws;
import
io.jsonwebtoken.impl.DefaultClaims
;
import
io.jsonwebtoken.impl.DefaultJws
;
import
lombok.Getter
;
import
net.minidev.json.JSONArray
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -63,7 +62,6 @@ public class AuthorizationServiceTest {
}
private
UserPrincipal
createAADUserPrincipal
(
String
claimName
,
String
claimValue
,
String
issuer
)
{
final
JSONArray
claims
=
new
JSONArray
();
final
JWTClaimsSet
jwtClaimsSet
=
new
JWTClaimsSet
.
Builder
()
//.subject("subject")
.
claim
(
claimName
,
claimValue
)
...
...
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