Commit 3086ccf1 authored by Abhishek Kumar (SLB)'s avatar Abhishek Kumar (SLB)
Browse files
parents c7523da6 7fd4f86c
This diff is collapsed.
......@@ -7,6 +7,7 @@
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<os-core-common.version>0.12.2</os-core-common.version>
</properties>
<licenses>
......
......@@ -30,8 +30,19 @@
<aws.version>1.11.1018</aws.version>
</properties>
<dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>${os-core-common.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-schema-core</artifactId>
......@@ -67,7 +78,7 @@
<dependency>
<groupId>org.opengroup.osdu.core.aws</groupId>
<artifactId>os-core-lib-aws</artifactId>
<version>0.12.0</version>
<version>0.12.2</version>
</dependency>
<dependency>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- ~ Copyright © Microsoft Corporation ~ ~ 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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<!--
~ Copyright © Microsoft Corporation
~
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>os-schema</artifactId>
<groupId>org.opengroup.osdu</groupId>
......@@ -25,8 +30,8 @@
<properties>
<azure.version>2.1.7</azure.version>
<osdu.corelibazure.version>0.12.0</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.12.0</osdu.oscorecommon.version>
<osdu.corelibazure.version>0.12.3</osdu.corelibazure.version>
<osdu.oscorecommon.version>0.12.2</osdu.oscorecommon.version>
<osdu.os-schema-core.version>0.13.0-SNAPSHOT</osdu.os-schema-core.version>
<mockito.version>1.10.19</mockito.version>
<cucumber.version>5.4.0</cucumber.version>
......@@ -182,12 +187,6 @@
<artifactId>spring-web</artifactId>
<version>5.3.7</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>4.1.68.Final</version>
</dependency>
</dependencies>
<build>
......
......@@ -7,4 +7,4 @@ ENV PROVIDER_NAME $PROVIDER_NAME
# Copy the jar to the production image from the builder stage.
COPY provider/schema-${PROVIDER_NAME}/target/os-schema-${PROVIDER_NAME}-*-spring-boot.jar schema.jar
# Run the web service on container startup.
CMD java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${PORT} -jar /app/schema.jar
CMD java -Djava.security.egd=file:/dev/./urandom -Dserver.port=${PORT} -Dlog4j.formatMsgNoLookups=true -jar /app/schema.jar
......@@ -11,6 +11,18 @@
<description>Google cloud related implementation staff.</description>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>${os-core-common.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.google.cloud/google-cloud-storage -->
<dependency>
......
......@@ -12,10 +12,22 @@
<properties>
<start-class>org.opengroup.osdu.schema.provider.ibm.app.SchemaIBMApplication</start-class>
<os-core-lib-ibm.version>0.12.0</os-core-lib-ibm.version>
<os-core-lib-ibm.version>0.12.1</os-core-lib-ibm.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>${os-core-common.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
......
......@@ -6,6 +6,7 @@ package org.opengroup.osdu.schema.impl.schemainfostore;
import static com.cloudant.client.api.query.Expression.eq;
import static com.cloudant.client.api.query.Operation.and;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collections;
......@@ -18,10 +19,13 @@ import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.opengroup.osdu.core.common.model.tenant.TenantInfo;
import org.opengroup.osdu.core.ibm.multitenancy.TenantFactory;
import org.opengroup.osdu.schema.constants.SchemaConstants;
......@@ -42,6 +46,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import org.springframework.web.context.annotation.RequestScope;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.cloudant.client.api.Database;
import com.cloudant.client.api.query.Expression;
......@@ -336,40 +343,31 @@ public class IbmSchemaInfoStore extends IbmDocumentStore implements ISchemaInfoS
} catch (Exception e) {
throw new UnauthorizedException("Unauthorized");
}
long numRecords = LIMIT_SIZE;
if (Long.valueOf(queryParams.getLimit()) != null && Long.valueOf(queryParams.getLimit()) != 0) {
numRecords = Long.valueOf(queryParams.getLimit());
}
String selectorWithoutFilter = "{ \"selector\": {} , \"limit\": "+numRecords+" }";
String finalQuery = null;
Selector selector = getSelector(queryParams);
if(selector == null)
finalQuery = selectorWithoutFilter;
else
finalQuery = new QueryBuilder(getSelector(queryParams)).limit(numRecords).build();
List<SchemaDoc> listSchemaDocs=new ArrayList<>();
List<SchemaDoc> filterSchemaDocs=new ArrayList<>();
Database dbWithTenant = null;
try {
dbWithTenant = getDatabaseForTenant(tenantId, SCHEMA_DATABASE);
} catch (MalformedURLException e) {
throw new ApplicationException("Unable to find database for tenant " + tenantId);
}
QueryResult<SchemaDoc> results = dbWithTenant.query(finalQuery, SchemaDoc.class);
try {
listSchemaDocs=dbWithTenant.getAllDocsRequestBuilder().includeDocs(true).build().getResponse().getDocsAs(SchemaDoc.class);
filterSchemaDocs=getSchemaRecordsBasedOnFilterCheck(listSchemaDocs,queryParams);
} catch (IOException e) {
throw new ApplicationException("Unable to find schema records for tenant " + tenantId);
}
List<SchemaInfo> schemaList = new LinkedList<>();
for (SchemaDoc doc : results.getDocs()) {
for (SchemaDoc doc : filterSchemaDocs) {
schemaList.add(doc.getSchemaInfo());
}
if (queryParams.getLatestVersion() != null && queryParams.getLatestVersion()) {
return getLatestVersionSchemaList(schemaList);
}
logger.info("list of filter Schema records:"+filterSchemaDocs.size());
return schemaList;
}
}
/**
* Method to fetch system schema info list
......@@ -480,4 +478,38 @@ public class IbmSchemaInfoStore extends IbmDocumentStore implements ISchemaInfoS
return schemaInfoObject.getSchemaIdentity().getAuthority()
.equalsIgnoreCase(previousSchemaInfo.getSchemaIdentity().getAuthority());
}
public List<SchemaDoc> getSchemaRecordsBasedOnFilterCheck(List<SchemaDoc> listSchemaDocs,QueryParams queryParams)
{
Stream<SchemaDoc> schemaDoc=listSchemaDocs.stream();
if(StringUtils.isNotEmpty(queryParams.getAuthority()))
schemaDoc=schemaDoc.filter(p->p.getSchemaInfo().getSchemaIdentity().getAuthority().equals(queryParams.getAuthority()));
if(StringUtils.isNotEmpty(queryParams.getEntityType()))
schemaDoc=schemaDoc.filter(p->p.getSchemaInfo().getSchemaIdentity().getEntityType().equals(queryParams.getEntityType()));
if(StringUtils.isNotEmpty(queryParams.getSource()))
schemaDoc=schemaDoc.filter(p->p.getSchemaInfo().getSchemaIdentity().getSource().equals(queryParams.getSource()));
if(StringUtils.isNotEmpty(queryParams.getStatus()))
schemaDoc=schemaDoc.filter(p->p.getSchemaInfo().getStatus().name().equals(queryParams.getStatus()));
if(StringUtils.isNotEmpty(queryParams.getScope()))
schemaDoc=schemaDoc.filter(p->p.getSchemaInfo().getScope().name().equals(queryParams.getScope()));
if(queryParams.getSchemaVersionMajor()!=null)
schemaDoc=schemaDoc.filter(p->p.getSchemaInfo().getSchemaIdentity().getSchemaVersionMajor().equals(queryParams.getSchemaVersionMajor()));
if(queryParams.getSchemaVersionMinor()!=null)
schemaDoc=schemaDoc.filter(p->p.getSchemaInfo().getSchemaIdentity().getSchemaVersionMinor().equals(queryParams.getSchemaVersionMinor()));
if(queryParams.getSchemaVersionPatch()!=null)
schemaDoc=schemaDoc.filter(p->p.getSchemaInfo().getSchemaIdentity().getSchemaVersionPatch().equals(queryParams.getSchemaVersionPatch()));
if(queryParams.getOffset()>=0)
schemaDoc=schemaDoc.skip(queryParams.getOffset());
return schemaDoc.collect(Collectors.toList());
}
}
......@@ -11,11 +11,14 @@ import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
......@@ -41,11 +44,18 @@ import org.opengroup.osdu.schema.model.SchemaIdentity;
import org.opengroup.osdu.schema.model.SchemaInfo;
import org.opengroup.osdu.schema.model.SchemaRequest;
import org.opengroup.osdu.schema.provider.ibm.SchemaDoc;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import com.cloudant.client.api.Database;
import com.cloudant.client.api.query.QueryResult;
import com.cloudant.client.api.views.AllDocsRequest;
import com.cloudant.client.api.views.AllDocsRequestBuilder;
import com.cloudant.client.api.views.AllDocsResponse;
import com.cloudant.client.org.lightcouch.DocumentConflictException;
......@@ -97,6 +107,19 @@ public class IbmSchemaInfoStoreTest {
@Mock
TenantInfo tenant;
@Mock
AllDocsRequestBuilder request;
@Mock
AllDocsRequestBuilder allDocsRequest;
@Mock
AllDocsRequest docsRequest;
@Mock
AllDocsResponse response;
@Rule
public ExpectedException expectedException = ExpectedException.none();
......@@ -491,37 +514,46 @@ public class IbmSchemaInfoStoreTest {
@Test
public void testGetSchemaInfoList_withoutqueryparam()
throws NotFoundException, ApplicationException, BadRequestException, MalformedURLException {
throws NotFoundException, ApplicationException, BadRequestException, IOException {
List<SchemaDoc> schemaDocsList = new LinkedList<>();
schemaDocsList.add(getMockSchemaDocObject());
Mockito.when(cloudantFactory.getDatabase(any(),anyString())).thenReturn(db);
Mockito.when(db.query(Mockito.any(),Mockito.any())).thenReturn(queryResult);
Mockito.when(queryResult.getDocs()).thenReturn(schemaDocsList);
Mockito.when(db.getAllDocsRequestBuilder()).thenReturn(request);
Mockito.when(request.includeDocs(true)).thenReturn(allDocsRequest);
Mockito.when(allDocsRequest.build()).thenReturn(docsRequest);
Mockito.when(docsRequest.getResponse()).thenReturn(response);
Mockito.when(response.getDocsAs(SchemaDoc.class)).thenReturn(schemaDocsList);
assertEquals(1,
schemaInfoStore.getSchemaInfoList(QueryParams.builder().limit(100).offset(0).build(), "test").size());
}
@Test
public void testGetSchemaInfoList_withoutqueryparam_SystemSchemas()
throws NotFoundException, ApplicationException, BadRequestException, MalformedURLException {
throws NotFoundException, ApplicationException, BadRequestException, IOException {
List<SchemaDoc> schemaDocsList = new LinkedList<>();
schemaDocsList.add(getMockSchemaDocObject());
Mockito.when(cloudantFactory.getDatabase(any(),anyString())).thenReturn(db);
Mockito.when(db.query(Mockito.any(),Mockito.any())).thenReturn(queryResult);
Mockito.when(queryResult.getDocs()).thenReturn(schemaDocsList);
Mockito.when(db.getAllDocsRequestBuilder()).thenReturn(request);
Mockito.when(request.includeDocs(true)).thenReturn(allDocsRequest);
Mockito.when(allDocsRequest.build()).thenReturn(docsRequest);
Mockito.when(docsRequest.getResponse()).thenReturn(response);
Mockito.when(response.getDocsAs(SchemaDoc.class)).thenReturn(schemaDocsList);
assertEquals(1,
schemaInfoStore.getSystemSchemaInfoList(QueryParams.builder().limit(100).offset(0).build()).size());
}
@Test
public void testGetSchemaInfoList_withqueryparam()
throws NotFoundException, ApplicationException, BadRequestException, MalformedURLException {
throws NotFoundException, ApplicationException, BadRequestException, IOException {
List<SchemaDoc> schemaDocsList = new LinkedList<>();
schemaDocsList.add(getMockSchemaDocObject());
Mockito.when(cloudantFactory.getDatabase(any(),anyString())).thenReturn(db);
Mockito.when(db.query(Mockito.any(),Mockito.any())).thenReturn(queryResult);
Mockito.when(queryResult.getDocs()).thenReturn(schemaDocsList);
assertEquals(1,
Mockito.when(db.getAllDocsRequestBuilder()).thenReturn(request);
Mockito.when(request.includeDocs(true)).thenReturn(allDocsRequest);
Mockito.when(allDocsRequest.build()).thenReturn(docsRequest);
Mockito.when(docsRequest.getResponse()).thenReturn(response);
Mockito.when(response.getDocsAs(SchemaDoc.class)).thenReturn(schemaDocsList);
assertEquals(0,
schemaInfoStore.getSchemaInfoList(QueryParams.builder().authority("test").source("test").entityType("test")
.schemaVersionMajor(1l).schemaVersionMinor(1l).scope("test").status("test").latestVersion(false)
.limit(100).offset(0).build(), "test").size());
......@@ -529,9 +561,14 @@ public class IbmSchemaInfoStoreTest {
@Test
public void testGetSchemaInfoList_latestVersionTrue_NoSchemaMatchScenario()
throws NotFoundException, ApplicationException, BadRequestException, MalformedURLException {
throws NotFoundException, ApplicationException, BadRequestException, IOException {
List<SchemaDoc> schemaDocsList = new LinkedList<>();
Mockito.when(cloudantFactory.getDatabase(any(),anyString())).thenReturn(db);
Mockito.when(db.query(Mockito.any(),Mockito.any())).thenReturn(queryResult);
Mockito.when(db.getAllDocsRequestBuilder()).thenReturn(request);
Mockito.when(request.includeDocs(true)).thenReturn(allDocsRequest);
Mockito.when(allDocsRequest.build()).thenReturn(docsRequest);
Mockito.when(docsRequest.getResponse()).thenReturn(response);
Mockito.when(response.getDocsAs(SchemaDoc.class)).thenReturn(schemaDocsList);
assertEquals(0,
schemaInfoStore
.getSchemaInfoList(QueryParams.builder().authority("test").source("test").entityType("test")
......@@ -541,8 +578,7 @@ public class IbmSchemaInfoStoreTest {
@Test
public void testGetSchemaInfoList_LatestVersionFunctionalityTest_SchemasWithDifferentMajorVersion()
throws NotFoundException, ApplicationException, BadRequestException, MalformedURLException {
throws NotFoundException, ApplicationException, BadRequestException, IOException {
SchemaIdentity schemaIdentity = new SchemaIdentity("authority","source","entityType",2L,11L,111L,"id");
SchemaInfo schemaInfo = new SchemaInfo(schemaIdentity,"createdBy", new Date(), SchemaStatus.DEVELOPMENT, SchemaScope.INTERNAL, schemaIdentity);
SchemaRequest schemaRequest = new SchemaRequest(schemaInfo, new Object());
......@@ -552,16 +588,19 @@ public class IbmSchemaInfoStoreTest {
schemaDocsList.add(schemaDoc);
schemaDocsList.add(latestSchemaDoc);
Mockito.when(cloudantFactory.getDatabase(any(),anyString())).thenReturn(db);
Mockito.when(db.query(Mockito.any(),Mockito.any())).thenReturn(queryResult);
Mockito.when(queryResult.getDocs()).thenReturn(schemaDocsList);
assertEquals(1, schemaInfoStore.getSchemaInfoList(
Mockito.when(db.getAllDocsRequestBuilder()).thenReturn(request);
Mockito.when(request.includeDocs(true)).thenReturn(allDocsRequest);
Mockito.when(allDocsRequest.build()).thenReturn(docsRequest);
Mockito.when(docsRequest.getResponse()).thenReturn(response);
Mockito.when(response.getDocsAs(SchemaDoc.class)).thenReturn(schemaDocsList);
assertEquals(0, schemaInfoStore.getSchemaInfoList(
QueryParams.builder().scope("test").status("test").latestVersion(true).limit(100).offset(0).build(),
"test").size());
}
@Test
public void testGetSchemaInfoList_LatestVersionFunctionalityTest_SchemasWithDifferentMinorVersion()
throws NotFoundException, ApplicationException, BadRequestException, MalformedURLException {
throws NotFoundException, ApplicationException, BadRequestException, IOException {
SchemaIdentity schemaIdentity = new SchemaIdentity("authority","source","entityType",1L,22L,111L,"id");
SchemaInfo schemaInfo = new SchemaInfo(schemaIdentity,"createdBy", new Date(), SchemaStatus.DEVELOPMENT, SchemaScope.INTERNAL, schemaIdentity);
SchemaRequest schemaRequest = new SchemaRequest(schemaInfo, new Object());
......@@ -571,16 +610,19 @@ public class IbmSchemaInfoStoreTest {
schemaDocsList.add(schemaDoc);
schemaDocsList.add(latestSchemaDoc);
Mockito.when(cloudantFactory.getDatabase(any(),anyString())).thenReturn(db);
Mockito.when(db.query(Mockito.any(),Mockito.any())).thenReturn(queryResult);
Mockito.when(queryResult.getDocs()).thenReturn(schemaDocsList);
assertEquals(1, schemaInfoStore.getSchemaInfoList(
Mockito.when(db.getAllDocsRequestBuilder()).thenReturn(request);
Mockito.when(request.includeDocs(true)).thenReturn(allDocsRequest);
Mockito.when(allDocsRequest.build()).thenReturn(docsRequest);
Mockito.when(docsRequest.getResponse()).thenReturn(response);
Mockito.when(response.getDocsAs(SchemaDoc.class)).thenReturn(schemaDocsList);
assertEquals(0, schemaInfoStore.getSchemaInfoList(
QueryParams.builder().scope("test").status("test").latestVersion(true).limit(100).offset(0).build(),
"test").size());
}
@Test
public void testGetSchemaInfoList_LatestVersionFunctionalityTest_SchemasWithDifferentSource()
throws NotFoundException, ApplicationException, BadRequestException, MalformedURLException {
throws NotFoundException, ApplicationException, BadRequestException, IOException {
SchemaIdentity schemaIdentity = new SchemaIdentity("authority","sourceChanged","entityType",1L,11L,111L,"id");
SchemaInfo schemaInfo = new SchemaInfo(schemaIdentity,"createdBy", new Date(), SchemaStatus.DEVELOPMENT, SchemaScope.INTERNAL, schemaIdentity);
......@@ -591,17 +633,20 @@ public class IbmSchemaInfoStoreTest {
schemaDocsList.add(schemaDoc);
schemaDocsList.add(latestSchemaDoc);
Mockito.when(cloudantFactory.getDatabase(any(),anyString())).thenReturn(db);
Mockito.when(db.query(Mockito.any(),Mockito.any())).thenReturn(queryResult);
Mockito.when(queryResult.getDocs()).thenReturn(schemaDocsList);
Mockito.when(db.getAllDocsRequestBuilder()).thenReturn(request);
Mockito.when(request.includeDocs(true)).thenReturn(allDocsRequest);
Mockito.when(allDocsRequest.build()).thenReturn(docsRequest);
Mockito.when(docsRequest.getResponse()).thenReturn(response);
Mockito.when(response.getDocsAs(SchemaDoc.class)).thenReturn(schemaDocsList);
assertEquals(2, schemaInfoStore.getSchemaInfoList(
assertEquals(0, schemaInfoStore.getSchemaInfoList(
QueryParams.builder().scope("test").status("test").latestVersion(true).limit(100).offset(0).build(),
"test").size());
}
@Test
public void testGetSchemaInfoList_LatestVersionFunctionalityTest_SchemasWithDifferentAuthority()
throws NotFoundException, ApplicationException, BadRequestException, MalformedURLException {
throws NotFoundException, ApplicationException, BadRequestException, IOException {
SchemaIdentity schemaIdentity = new SchemaIdentity("authorityChanged","source","entityType",1L,11L,111L,"id");
SchemaInfo schemaInfo = new SchemaInfo(schemaIdentity,"createdBy", new Date(), SchemaStatus.DEVELOPMENT, SchemaScope.INTERNAL, schemaIdentity);
......@@ -613,18 +658,21 @@ public class IbmSchemaInfoStoreTest {
schemaDocsList.add(latestSchemaDoc);
Mockito.when(headers.getPartitionIdWithFallbackToAccountId()).thenReturn(dataPartitionId);
Mockito.when(cloudantFactory.getDatabase(any(),anyString())).thenReturn(db);
Mockito.when(db.query(Mockito.any(),Mockito.any())).thenReturn(queryResult);
Mockito.when(queryResult.getDocs()).thenReturn(schemaDocsList);
Mockito.when(db.getAllDocsRequestBuilder()).thenReturn(request);
Mockito.when(request.includeDocs(true)).thenReturn(allDocsRequest);
Mockito.when(allDocsRequest.build()).thenReturn(docsRequest);
Mockito.when(docsRequest.getResponse()).thenReturn(response);
Mockito.when(response.getDocsAs(SchemaDoc.class)).thenReturn(schemaDocsList);
Mockito.when(tenant.getName()).thenReturn(dataPartitionId);
assertEquals(2, schemaInfoStore.getSchemaInfoList(
assertEquals(0, schemaInfoStore.getSchemaInfoList(
QueryParams.builder().scope("test").status("test").latestVersion(true).limit(100).offset(0).build(),
"test").size());
}
@Test
public void testGetSchemaInfoList_LatestVersionFunctionalityTest_SchemasWithDifferentEntity()
throws NotFoundException, ApplicationException, BadRequestException, MalformedURLException {
throws NotFoundException, ApplicationException, BadRequestException, IOException {
SchemaIdentity schemaIdentity = new SchemaIdentity("authority","source","entityTypeChanged",1L,11L,111L,"id");
SchemaInfo schemaInfo = new SchemaInfo(schemaIdentity,"createdBy", new Date(), SchemaStatus.DEVELOPMENT, SchemaScope.INTERNAL, schemaIdentity);
SchemaRequest schemaRequest = new SchemaRequest(schemaInfo, new Object());
......@@ -636,10 +684,13 @@ public class IbmSchemaInfoStoreTest {
schemaDocsList.add(schemaDoc);
schemaDocsList.add(latestSchemaDoc);
Mockito.when(cloudantFactory.getDatabase(any(),anyString())).thenReturn(db);
Mockito.when(db.query(Mockito.any(),Mockito.any())).thenReturn(queryResult);
Mockito.when(queryResult.getDocs()).thenReturn(schemaDocsList);
Mockito.when(db.getAllDocsRequestBuilder()).thenReturn(request);
Mockito.when(request.includeDocs(true)).thenReturn(allDocsRequest);
Mockito.when(allDocsRequest.build()).thenReturn(docsRequest);
Mockito.when(docsRequest.getResponse()).thenReturn(response);
Mockito.when(response.getDocsAs(SchemaDoc.class)).thenReturn(schemaDocsList);
assertEquals(2, schemaInfoStore.getSchemaInfoList(
assertEquals(0, schemaInfoStore.getSchemaInfoList(
QueryParams.builder().scope("test").status("test").latestVersion(true).limit(100).offset(0).build(),
"test").size());
}
......
......@@ -32,6 +32,18 @@
<description>Schema Service GCP Anthos</description>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
<artifactId>os-core-common</artifactId>
<version>${os-core-common.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>
......@@ -84,4 +96,4 @@
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
</project>
......@@ -13,9 +13,20 @@
<properties>
<springfox-version>2.7.0</springfox-version>
<os-core-common.version>0.12.0</os-core-common.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.opengroup.osdu</groupId>