Commit 351a824c authored by harshit aggarwal's avatar harshit aggarwal
Browse files

resolving conflicts from master

parents 0394ff2d 308ff5c7
Pipeline #23932 failed with stages
in 2 minutes and 19 seconds
......@@ -131,7 +131,8 @@ Feature: Covers all positive and negative test cases around WKS transformation s
| relatedEntityPayload | parentPayload | expectedRelationshipBlock |
| "/input_payloads/relationship/raw_having_wks_created_log_entity.json" | "/input_payloads/relationship/recordRelatedToEntityHavingWksCreatedLogEntity.json" | "/input_payloads/relationship/expectedRelationship_for_rawHavingWksCreated.json" |
@RelationshipValidation
@Not_yet_implemented_for_gitlab_gcp
Scenario Outline: WKS record relationships block should show relation to wks record created by wks service, with mapping definition targeted to schema of same authority and having higher major version
Given I hit Storage service put end point with <relatedEntityPayload> to persist a record say raw1
And I verify that three wks records are created for this raw record raw1
......@@ -139,7 +140,7 @@ Feature: Covers all positive and negative test cases around WKS transformation s
When I hit Storage service put end point with <parentPayload> whose raw record contains relationship to record raw1
Then Transformed record should contain relationship to wks with same authority of raw1 <relatedEntityPayload> and with higher major version as per <expectedRelationshipBlock>
Examples:
Examples:
| relatedEntityPayload | relatedEntityPayload2 | parentPayload | expectedRelationshipBlock |
| "/input_payloads/relationship/raw_having_wks_created_well_entity.json" | "/input_payloads/relationship/recordRelatedToAnotherRawButNotCreatedByWKSService.json" | "/input_payloads/relationship/recordRelatedToEntityHavingWksCreatedWellEntity.json" | "/input_payloads/relationship/expectedRelationship_for_rawHavingWksCreated.json" |
......
......@@ -3,7 +3,7 @@
"data": {
"relationships": {
"wellbore": {
"id": "non:existent:record-recordDoesNotExistInSystem"
"id": "non:existent:record-recordDoesNotExistInSystem-0a03169487847"
}
}
},
......
......@@ -4,6 +4,8 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.opengroup.osdu.wks.enums.MappingScope;
import java.sql.Timestamp;
......@@ -12,6 +14,7 @@ import java.sql.Timestamp;
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class MappingInfo {
private String id;
private String mappingId;
......
package org.opengroup.osdu.wks.service;
import org.opengroup.osdu.wks.exceptions.ApplicationException;
import org.opengroup.osdu.wks.model.MappingInfo;
import org.opengroup.osdu.wks.model.MappingsModel;
import java.util.List;
......@@ -8,4 +9,6 @@ import java.util.List;
public interface MappingService {
List<MappingsModel> getMapping(String kind) throws ApplicationException;
List<MappingInfo> getMappingInfos(String authority, String entity, String source, String majorVersion);
}
......@@ -31,5 +31,10 @@ public class MappingServiceImpl implements MappingService {
}
return mappingStore.getMappingFilesFromStorage(mappingInfos);
}
@Override
public List<MappingInfo> getMappingInfos(final String authority, final String entity, final String source, final String majorVersion) {
return mappingStore.getMappingInfo(authority, entity, source, majorVersion);
}
}
......@@ -7,7 +7,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.opengroup.osdu.wks.constants.Constants;
......@@ -21,7 +20,7 @@ import org.opengroup.osdu.wks.model.SearchByAncestryQuery;
import org.opengroup.osdu.wks.model.SearchQuery;
import org.opengroup.osdu.wks.model.SearchRequestPayload;
import org.opengroup.osdu.wks.model.UpdatedRelationshipBlock;
import org.opengroup.osdu.wks.provider.interfaces.MappingStore;
import org.opengroup.osdu.wks.service.MappingService;
import org.opengroup.osdu.wks.service.SearchService;
import org.opengroup.osdu.wks.service.StorageService;
import org.slf4j.Logger;
......@@ -45,17 +44,20 @@ public class RelationshipBlockHandler {
private String targetSchemaKindValue;
private MappingStore mappingStore;
private MappingService mappingService;
private KindUtil kindUtil;
@Autowired
public RelationshipBlockHandler(
StorageService storageService,
SearchService searchService,
MappingStore mappingStore) {
MappingService mappingService,
KindUtil kindUtil) {
this.storageService = storageService;
this.searchService = searchService;
this.mappingStore = mappingStore;
this.mappingService = mappingService;
this.kindUtil = kindUtil;
}
public UpdatedRelationshipBlock updateRelationshipBlockWithWksIds(Tree rawRelationshipsBlockTree, String targetSchemaKind) {
......@@ -107,7 +109,7 @@ public class RelationshipBlockHandler {
try {
wksRelationship = getRelationshipBlockWithWksIds(rawRelationship);
} catch (ApplicationException e) {
LOGGER.warn(e.getMessage(), e);
LOGGER.info(e.getMessage(), e);
}
if(wksRelationship != null) {
wksRelationships.add(wksRelationship);
......@@ -124,16 +126,92 @@ public class RelationshipBlockHandler {
return rawRelationship;
}
private List<String> getWksIds(List<String> rawIds) {
return rawIds.stream().map(this::getWksId).collect(Collectors.toList());
private String getRelatedRecordIdUsingMapping(String relatedRecordId) {
Optional<String> rawRecordOption = storageService.getRecord(relatedRecordId);
if (rawRecordOption.isPresent()) {
Optional<String> relatedRecordKindOption = getRelatedRecordKind(rawRecordOption.get());
if (relatedRecordKindOption.isPresent()) {
Optional<String> relatedRecordTargetKind = getTargetKind(relatedRecordKindOption.get());
if (relatedRecordTargetKind.isPresent()) {
return WksIdGenerator.createRecordId(relatedRecordId, relatedRecordTargetKind.get());
}
}
}
return relatedRecordId;
}
private Optional<String> getRelatedRecordKind(String rawRecord) {
try {
String relatedRecordKind = new Tree(rawRecord).get("kind").asString();
return Optional.of(relatedRecordKind);
} catch (Exception e) {
LOGGER.warn("Error retrieving related record kind so keeping related record id");
}
return Optional.ofNullable(null);
}
private Optional<String> getTargetKind(String kind) {
Optional<MappingInfo> mappingInfoOption = getLatestMappingInfoWithRelatedAuthority(kind);
if(mappingInfoOption.isPresent()) {
MappingInfo mappingInfo = mappingInfoOption.get();
return Optional.of(kindUtil.prepareKind(mappingInfo.getTargetSchemaAuthority(),
mappingInfo.getTargetSchemaSource(), mappingInfo.getTargetEntityType(),
mappingInfo.getTargetSchemaMajorVersion(), "0", "0"));
}
else {
return Optional.ofNullable(null);
}
}
/**
* This method takes kind of related raw record. Using kind it finds all target
* mapping infos and then find related mapping infos using authority of
* container raw record. After this it returns Optional Mapping Info which has
* highest major version. Here we assume that mapping info version is not
* available only mapping major version is available.
*
* @param kind
* @return Optional<MappingInfo>
*/
private Optional<MappingInfo> getLatestMappingInfoWithRelatedAuthority(String kind) {
List<MappingInfo> mappingInfos = mappingService.getMappingInfos(kindUtil.retrieveAuthorityName(kind),
kindUtil.retrieveEntityName(kind), kindUtil.retrieveSourceName(kind),
kindUtil.retrieveMajorVersion(kind));
if (mappingInfos.isEmpty()) {
return Optional.ofNullable(null);
}
String authority = kindUtil.retrieveAuthorityName(targetSchemaKindValue);
mappingInfos = mappingInfos.stream()
.filter(mappingInfo -> mappingInfo.getTargetSchemaAuthority().equalsIgnoreCase(authority))
.collect(Collectors.toList());
return mappingInfos.stream().max(Comparator.comparing(MappingInfo::getMappingSchemaMajorVersion));
}
private List<String> getWksIds(List<String> relatedRawIds) {
List<String> wksIds = new ArrayList<>();
for(String relatedRawId : relatedRawIds) {
Optional<String> wksIdOptional = getWksId(relatedRawId);
if(wksIdOptional.isPresent()) {
wksIds.add(wksIdOptional.get());
}
else {
String relatedId = getRelatedRecordIdUsingMapping(relatedRawId);
wksIds.add(relatedId);
}
}
return wksIds;
}
private String getWksId(String rawId) {
private Optional<String> getWksId(String rawId) {
String searchResults = null;
// TODO Look out for performance improvement through caching
Optional<String> optionalRawRecord = storageService.getRecord(rawId);
if (!optionalRawRecord.isPresent()) {
return rawId;
return Optional.ofNullable(null);
}
String rawRecordJson = optionalRawRecord.get();
SearchRequestPayload searchRequestPayload = prepareSearchQueryPayload(rawRecordJson);
......@@ -150,16 +228,16 @@ public class RelationshipBlockHandler {
return extractWksIdFromSearchResults(searchResults, rawId, rawKind);
}
private String extractWksIdFromSearchResults(String searchResults, String rawId, Kind rawKind) {
private Optional<String> extractWksIdFromSearchResults(String searchResults, String rawId, Kind rawKind) {
List<WksInfo> wksInfos = getWksInfos(searchResults);
if (noWksFound(wksInfos)) {
LOGGER.info("No matching WKS found for record id: {}", rawId);
return rawId;
return Optional.ofNullable(null);
}
return getUniqueWksId(rawId, wksInfos, rawKind);
}
private String getUniqueWksId(String rawId, List<WksInfo> wksInfos, Kind rawKind) {
private Optional<String> getUniqueWksId(String rawId, List<WksInfo> wksInfos, Kind rawKind) {
// Add the logic for filtering WKS Records on the below criteria till unique Record found
// 1. Choose records created by WKS service only
// 2. Choose records having same universe as that of the mapping file
......@@ -170,7 +248,7 @@ public class RelationshipBlockHandler {
LOGGER.info("Total {} Records created by WKS service", wksGeneratedByWKSService.size());
if(wksGeneratedByWKSService.isEmpty()) {
return rawId;
return Optional.ofNullable(null);
}
String targetSchemaAuthority = targetSchemaKindValue.split(Constants.COLON_SEPARATOR)[0];
......@@ -179,18 +257,18 @@ public class RelationshipBlockHandler {
LOGGER.info("Total {} Records have same authority as that of target schema", wksGeneratedByWKSService.size());
if(wksFromGivenAuthority.isEmpty()) {
return rawId;
return Optional.ofNullable(null);
}
if(wksFromGivenAuthority.size() == 1) {
return wksFromGivenAuthority.get(0).getId();
return Optional.of(wksFromGivenAuthority.get(0).getId());
}
List<WksInfo> wksSortedOnMajorVersion = wksFromGivenAuthority.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
LOGGER.info("Unique WKS Record with id: {} found for relationship with Record {}", wksSortedOnMajorVersion.get(0).getId(), rawId);
return wksSortedOnMajorVersion.get(0).getId();
return Optional.of(wksSortedOnMajorVersion.get(0).getId());
}
private List<WksInfo> getWKSRecordsCreatedByWKSService(String rawId, List<WksInfo> wksInfos, Kind rawKind) {
......@@ -198,7 +276,7 @@ public class RelationshipBlockHandler {
String majorVersion = rawKind.getVersion().split("\\.")[0];
// TODO Look out for performance improvement through caching (FYI: Once mapping service comes
// online the entire logic of datastore look up will become obsolete)
List<MappingInfo> mappingInfos = mappingStore.getMappingInfo(rawKind.getAuthority(), rawKind.getEntityType(), rawKind.getSource(), majorVersion);
List<MappingInfo> mappingInfos = mappingService.getMappingInfos(rawKind.getAuthority(), rawKind.getEntityType(), rawKind.getSource(), majorVersion);
Set<String>wksRecordIds = new HashSet<>();
for(MappingInfo mappingInfo : mappingInfos) {
String targetSchemaKind = generateKind(mappingInfo.getTargetSchemaAuthority(), mappingInfo.getTargetSchemaSource(), mappingInfo.getTargetEntityType(), mappingInfo.getTargetSchemaMajorVersion());
......@@ -228,71 +306,10 @@ public class RelationshipBlockHandler {
return wksRecordId.split("\\.")[1];
}
private String retrieveUniqueWksIdBasedOnPriority(String rawId, List<WksInfo> wksWithLatestMajorVersionInKind) {
Optional<String> optionalUniqueWksGenerateByWksService = fetchWksGeneratedByWksService(rawId,
wksWithLatestMajorVersionInKind);
return optionalUniqueWksGenerateByWksService
.orElseGet(() -> retrieveWksIdWithLatestRecordVersion(wksWithLatestMajorVersionInKind));
}
private String retrieveWksIdWithLatestRecordVersion(List<WksInfo> wksWithLatestMajorVersionInKind) {
List<WksInfo> sortWksByLatestRecordVersion = wksWithLatestMajorVersionInKind.stream()
.sorted((o1, o2) -> (int) (o2.getVersion() - o1.getVersion()))
.collect(Collectors.toList());
return sortWksByLatestRecordVersion.get(0).getId();
}
private boolean multipleMatchingWksHavingSameMajorVersion(List<WksInfo> wksWithLatestMajorVersionInKind) {
return wksWithLatestMajorVersionInKind.size() != 1;
}
private Optional<String> fetchWksGeneratedByWksService(String rawId,
List<WksInfo> wksWithLatestMajorVersionInKind) {
List<Tree> wksCreatedByWksService = retrieveWksCreatedByWksService(wksWithLatestMajorVersionInKind, rawId);
if (noUniqueWksFound(wksCreatedByWksService)) {
return Optional.empty();
} else {
Tree wksRecordTree = wksCreatedByWksService.get(0);
return Optional.of(wksRecordTree.get("id").asString());
}
}
private List<Tree> retrieveWksCreatedByWksService(List<WksInfo> wksWithLatestMajorVersionInKind, String rawId) {
return wksWithLatestMajorVersionInKind
.stream()
.map(wksInfo -> storageService.getRecord(wksInfo.getId()))
.filter(Optional::isPresent)
.map(Optional::get)
.map(JsonTreeUtil::toTree)
.filter(wksRecordTree -> isWksCreatedByWksService(wksRecordTree, rawId))
.collect(Collectors.toList());
}
private boolean noUniqueWksFound(List<Tree> wksCreatedByWksService) {
return wksCreatedByWksService.size() != 1;
}
private List<WksInfo> retrieveWksWithLatestMajorVersionInKind(List<WksInfo> wksInfos) {
List<WksInfo> sortedWksInfos = sortWKSByMajorVersion(wksInfos);
Integer latestMajorVersion = sortedWksInfos.get(0).fetchMajorVersionFromKind();
return sortedWksInfos
.stream()
.filter(wksHavingLatestMajorVersion(latestMajorVersion))
.collect(Collectors.toList());
}
private boolean noWksFound(List<WksInfo> wksInfos) {
return wksInfos.isEmpty();
}
private List<WksInfo> sortWKSByMajorVersion(List<WksInfo> wksInfos) {
return wksInfos.stream().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
}
private Predicate<WksInfo> wksHavingLatestMajorVersion(Integer latestMajorVersion) {
return wksInfo -> latestMajorVersion.equals(wksInfo.fetchMajorVersionFromKind());
}
private List<WksInfo> getWksInfos(String searchResults) {
try {
Tree searchResult = new Tree(searchResults);
......@@ -315,12 +332,4 @@ public class RelationshipBlockHandler {
SearchQuery searchQuery = new SearchByAncestryQuery(rawRecordId, rawRecordVersion);
return new SearchRequestPayload(wksKind, searchQuery);
}
private boolean isWksCreatedByWksService(Tree wksRecordTree, String rawId) {
if (null != wksRecordTree.get("id") && null != wksRecordTree.get("kind")) {
String generatedWksId = WksIdGenerator.createRecordId(rawId, wksRecordTree.get("kind").asString());
return generatedWksId.equals(wksRecordTree.get("id").asString());
}
return false;
}
}
package org.opengroup.osdu.wks.util;
import java.nio.charset.StandardCharsets;
import java.util.stream.Stream;
import com.google.common.hash.Hashing;
import org.opengroup.osdu.wks.constants.Constants;
......
......@@ -23,7 +23,7 @@ import org.mockito.junit.jupiter.MockitoExtension;
import org.opengroup.osdu.wks.exceptions.ApplicationException;
import org.opengroup.osdu.wks.model.MappingInfo;
import org.opengroup.osdu.wks.model.UpdatedRelationshipBlock;
import org.opengroup.osdu.wks.provider.interfaces.MappingStore;
import org.opengroup.osdu.wks.service.MappingService;
import org.opengroup.osdu.wks.service.SearchService;
import org.opengroup.osdu.wks.service.StorageService;
import org.springframework.core.io.ClassPathResource;
......@@ -55,7 +55,10 @@ class RelationshipBlockHandlerTest {
private SearchService searchService;
@Mock
private MappingStore mappingStore;
private MappingService mappingService;
@Mock
private KindUtil kindUtil;
@InjectMocks
private RelationshipBlockHandler relationshipBlockHandler;
......@@ -69,17 +72,66 @@ class RelationshipBlockHandlerTest {
String searchResults = findJsonTree("search_results_wks_generated_record.json").toString();
List<MappingInfo> mappingInfoList = new ArrayList<>();
MappingInfo mappingInfo = new MappingInfo();
mappingInfo.setTargetSchemaAuthority(AUTHORITY);
mappingInfo.setTargetEntityType(ENTITY);
mappingInfo.setTargetSchemaSource(SOURCE);
mappingInfo.setTargetSchemaMajorVersion(MAJOR_VERSION);
MappingInfo mappingInfo = createMappingInfo();
mappingInfoList.add(mappingInfo);
when(storageService.getRecord(any(String.class))).thenReturn(Optional.of(wksRecordStr));
when(searchService.query(any(String.class))).thenReturn(searchResults);
when(mappingService.getMappingInfos(eq(AUTHORITY), eq(ENTITY), eq(SOURCE), eq(MAJOR_VERSION))).thenReturn(mappingInfoList);
UpdatedRelationshipBlock response = relationshipBlockHandler
.updateRelationshipBlockWithWksIds(rawRelationshipsBlockTree, TARGET_SCHEMA_KIND);
assertNotNull(response);
assertNotNull(response.getRelationshipTree());
assertTrue(response.getPendingEnitites().size() == 0);
}
@Test
public void testRelationshipForOneToManyRelationshipWhenNoRelatedWksIdFound() throws IOException, ApplicationException {
Tree rawRecordWithRelationship = findJsonTree("raw_record_valid_relationship_block_oneToMany.json");
Tree rawRelationshipsBlockTree = rawRecordWithRelationship.get("data.relationships");
String wksRecordStr = findJsonTree("wks_record.json").toString();
String searchResults = findJsonTree("search_results_wks_not_found.json").toString();
List<MappingInfo> mappingInfoList = new ArrayList<>();
MappingInfo mappingInfo = createMappingInfo();
mappingInfoList.add(mappingInfo);
when(storageService.getRecord(any(String.class))).thenReturn(Optional.of(wksRecordStr));
when(searchService.query(any(String.class))).thenReturn(searchResults);
when(mappingService.getMappingInfos(eq(AUTHORITY), eq(ENTITY), eq(SOURCE), eq(MAJOR_VERSION))).thenReturn(mappingInfoList);
UpdatedRelationshipBlock response = relationshipBlockHandler
.updateRelationshipBlockWithWksIds(rawRelationshipsBlockTree, TARGET_SCHEMA_KIND);
assertNotNull(response);
assertNotNull(response.getRelationshipTree());
assertTrue(response.getPendingEnitites().size() != 0);
}
@Test
public void testRelationshipForOneToManyRelationshipWhenNoRelatedWksIdFoundForBoth()
throws IOException, ApplicationException {
Tree rawRecordWithRelationship = findJsonTree("raw_record_valid_relationship_block_oneToMany.json");
Tree rawRelationshipsBlockTree = rawRecordWithRelationship.get("data.relationships");
String wksRecordStr = findJsonTree("wks_record.json").toString();
String searchResults = findJsonTree("search_results_wks_not_found.json").toString();
List<MappingInfo> mappingInfoList = new ArrayList<>();
MappingInfo mappingInfo = createMappingInfo();
mappingInfoList.add(mappingInfo);
when(kindUtil.prepareKind(any(), any(), any(), any(), any(), any())).thenReturn(TARGET_SCHEMA_KIND);
when(kindUtil.retrieveAuthorityName(TARGET_SCHEMA_KIND)).thenReturn(AUTHORITY);
when(storageService.getRecord(any(String.class))).thenReturn(Optional.of(wksRecordStr));
when(searchService.query(any(String.class))).thenReturn(searchResults);
when(mappingStore.getMappingInfo(eq(AUTHORITY), eq(ENTITY), eq(SOURCE), eq(MAJOR_VERSION))).thenReturn(mappingInfoList);
when(mappingService.getMappingInfos(any(), any(), any(), any())).thenReturn(mappingInfoList);
UpdatedRelationshipBlock response = relationshipBlockHandler
.updateRelationshipBlockWithWksIds(rawRelationshipsBlockTree, TARGET_SCHEMA_KIND);
......@@ -88,7 +140,35 @@ class RelationshipBlockHandlerTest {
assertNotNull(response.getRelationshipTree());
assertTrue(response.getPendingEnitites().size() == 0);
}
@Test
public void testRelationshipForOneToManyRelationshipWhenNoRelatedWksIdFoundForOne()
throws IOException, ApplicationException {
Tree rawRecordWithRelationship = findJsonTree("raw_record_valid_relationship_block_oneToMany.json");
Tree rawRelationshipsBlockTree = rawRecordWithRelationship.get("data.relationships");
String wksRecordStr = findJsonTree("wks_record.json").toString();
String searchResults = findJsonTree("search_results_wks_not_found.json").toString();
List<MappingInfo> mappingInfoList = new ArrayList<>();
MappingInfo mappingInfo = createMappingInfo();
mappingInfoList.add(mappingInfo);
when(kindUtil.prepareKind(any(), any(), any(), any(), any(), any())).thenReturn(TARGET_SCHEMA_KIND);
when(kindUtil.retrieveAuthorityName(TARGET_SCHEMA_KIND)).thenReturn(AUTHORITY);
when(storageService.getRecord(any(String.class))).thenReturn(Optional.of(wksRecordStr));
when(searchService.query(any(String.class))).thenReturn(searchResults);
when(mappingService.getMappingInfos(any(), any(), any(), any())).thenReturn(mappingInfoList);
UpdatedRelationshipBlock response = relationshipBlockHandler
.updateRelationshipBlockWithWksIds(rawRelationshipsBlockTree, TARGET_SCHEMA_KIND);
assertNotNull(response);
assertNotNull(response.getRelationshipTree());
assertTrue(response.getPendingEnitites().size() == 0);
}
@Test
public void testRelationshipForOneToOneRelationshipWhenNoWKSRecordCreatedByService() throws IOException, ApplicationException {
Tree rawRecordWithRelationship = findJsonTree("raw_record_valid_relationship_block_oneToOne.json");
......@@ -98,17 +178,13 @@ class RelationshipBlockHandlerTest {
String searchResults = findJsonTree("search_results_wks_not_found.json").toString();
List<MappingInfo> mappingInfoList = new ArrayList<>();
MappingInfo mappingInfo = new MappingInfo();
mappingInfo.setTargetSchemaAuthority(AUTHORITY);
mappingInfo.setTargetEntityType(ENTITY);
mappingInfo.setTargetSchemaSource(SOURCE);
mappingInfo.setTargetSchemaMajorVersion(MAJOR_VERSION);
MappingInfo mappingInfo = createMappingInfo();
mappingInfoList.add(mappingInfo);
when(storageService.getRecord(any(String.class))).thenReturn(Optional.of(wksRecordStr));
when(searchService.query(any(String.class))).thenReturn(searchResults);
when(mappingStore.getMappingInfo(eq(AUTHORITY), eq(ENTITY), eq(SOURCE), eq(MAJOR_VERSION))).thenReturn(mappingInfoList);
when(mappingService.getMappingInfos(eq(AUTHORITY), eq(ENTITY), eq(SOURCE), eq(MAJOR_VERSION))).thenReturn(mappingInfoList);
UpdatedRelationshipBlock response = relationshipBlockHandler
.updateRelationshipBlockWithWksIds(rawRelationshipsBlockTree, TARGET_SCHEMA_KIND);
......@@ -147,7 +223,7 @@ class RelationshipBlockHandlerTest {
mappingInfoList.add(mappingInfo1);
mappingInfoList.add(mappingInfo2);
when(mappingStore.getMappingInfo(eq(AUTHORITY), eq(ENTITY), eq(SOURCE), eq(MAJOR_VERSION))).thenReturn(mappingInfoList);
when(mappingService.getMappingInfos(eq(AUTHORITY), eq(ENTITY), eq(SOURCE), eq(MAJOR_VERSION))).thenReturn(mappingInfoList);
when(storageService.getRecord(any())).thenReturn(Optional.of(wksRecordStr));
when(searchService.query(any(String.class))).thenReturn(searchResults);
......@@ -177,7 +253,7 @@ class RelationshipBlockHandlerTest {
mappingInfoList.add(mappingInfo1);
mappingInfoList.add(mappingInfo2);
when(mappingStore.getMappingInfo(eq(AUTHORITY), eq(ENTITY), eq(SOURCE), eq(MAJOR_VERSION))).thenReturn(mappingInfoList);
when(mappingService.getMappingInfos(eq(AUTHORITY), eq(ENTITY), eq(SOURCE), eq(MAJOR_VERSION))).thenReturn(mappingInfoList);
when(storageService.getRecord(any())).thenReturn(Optional.of(wksRecordStr));
when(searchService.query(any(String.class))).thenReturn(searchResults);
......@@ -225,5 +301,14 @@ class RelationshipBlockHandlerTest {
return mapper.readValue(file, new TypeReference<Map<String, Object>>() {
});
}
private MappingInfo createMappingInfo() {
MappingInfo mappingInfo = new MappingInfo();
mappingInfo.setTargetSchemaAuthority(AUTHORITY);
mappingInfo.setTargetEntityType(ENTITY);
mappingInfo.setTargetSchemaSource(SOURCE);
mappingInfo.setTargetSchemaMajorVersion(MAJOR_VERSION);
return mappingInfo;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment