Commit a3697d9f authored by Jeremy Destin's avatar Jeremy Destin Committed by Célia Michotey
Browse files

Fix: Fix the tests by adding mcdp service to the tests. Clean some code.

parent f07a9089
package fr.inra.urgi.faidare.elasticsearch.repository.impl; package fr.inra.urgi.faidare.elasticsearch.repository.impl;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import fr.inra.urgi.faidare.elasticsearch.ESRequestFactory; import fr.inra.urgi.faidare.elasticsearch.ESRequestFactory;
import fr.inra.urgi.faidare.elasticsearch.ESResponseParser; import fr.inra.urgi.faidare.elasticsearch.ESResponseParser;
import fr.inra.urgi.faidare.elasticsearch.document.DocumentAnnotationUtil; import fr.inra.urgi.faidare.elasticsearch.document.DocumentAnnotationUtil;
...@@ -66,19 +64,6 @@ public class ESGenericGetByIdRepository<VO> implements ESGetByIdRepository<VO> { ...@@ -66,19 +64,6 @@ public class ESGenericGetByIdRepository<VO> implements ESGetByIdRepository<VO> {
// Parse result list // Parse result list
List<? extends VO> resultList = parser.parseHits(result, voClass); List<? extends VO> resultList = parser.parseHits(result, voClass);
System.out.println("");
System.out.println("BEGIN");
System.out.println("");
ObjectWriter ow = new ObjectMapper().writer().withDefaultPrettyPrinter();
String json = ow.writeValueAsString(result);
System.out.println(json);
System.out.println("END");
System.out.println("");
if (resultList != null && !resultList.isEmpty()) { if (resultList != null && !resultList.isEmpty()) {
if (resultList.size() > 1) { if (resultList.size() > 1) {
// Should never happen // Should never happen
......
...@@ -103,7 +103,7 @@ public class ESSetUp { ...@@ -103,7 +103,7 @@ public class ESSetUp {
if (response.hasFailures()) { if (response.hasFailures()) {
System.err.println(response.buildFailureMessage()); System.err.println(response.buildFailureMessage());
throw new RuntimeException("Indexing failed (index name: '" + indexName + "'"); throw new RuntimeException("Indexing failed (index name: '" + indexName + "')");
} }
} }
......
...@@ -14,8 +14,22 @@ import { CardSectionComponent } from '../card-section/card-section.component'; ...@@ -14,8 +14,22 @@ import { CardSectionComponent } from '../card-section/card-section.component';
import { CardRowComponent } from '../card-row/card-row.component'; import { CardRowComponent } from '../card-row/card-row.component';
import { CardTableComponent } from '../card-table/card-table.component'; import { CardTableComponent } from '../card-table/card-table.component';
import { MapComponent } from '../map/map.component'; import { MapComponent } from '../map/map.component';
import { BrapiGermplasmAttributes, BrapiGermplasmPedigree, BrapiResult, BrapiSibling } from '../models/brapi.model'; import {
import { Donor, Germplasm, GermplasmInstitute, GermplasmSet, Institute, Site } from '../models/gnpis.model'; BrapiCollectingSite,
BrapiGermplasmAttributes,
BrapiGermplasmMcpd,
BrapiGermplasmPedigree,
BrapiInstitute,
BrapiResult,
BrapiSibling
} from '../models/brapi.model';
import {
Donor,
Germplasm,
GermplasmInstitute,
GermplasmSet,
Institute
} from '../models/gnpis.model';
import { DataDiscoverySource } from '../models/data-discovery.model'; import { DataDiscoverySource } from '../models/data-discovery.model';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { XrefsComponent } from '../xrefs/xrefs.component'; import { XrefsComponent } from '../xrefs/xrefs.component';
...@@ -84,6 +98,17 @@ describe('GermplasmCardComponent', () => { ...@@ -84,6 +98,17 @@ describe('GermplasmCardComponent', () => {
logo: null logo: null
}; };
const brapiInstitute: BrapiInstitute = {
instituteName: 'INRAE URGI',
instituteCode: '78000',
acronym: 'INRAE',
organisation: 'inrae',
instituteType: 'lab',
webSite: 'www.labo.fr',
instituteAddress: '18',
logo: null
};
const gnpisGermplasmInstitute: GermplasmInstitute = { const gnpisGermplasmInstitute: GermplasmInstitute = {
...gnpisInstitute, ...gnpisInstitute,
institute: gnpisInstitute, institute: gnpisInstitute,
...@@ -96,6 +121,20 @@ describe('GermplasmCardComponent', () => { ...@@ -96,6 +121,20 @@ describe('GermplasmCardComponent', () => {
distributionStatus: null distributionStatus: null
}; };
const collectingSite: BrapiCollectingSite = {
locationDbId: 'FR-78-INRAE',
locationName: 'Versailles',
coordinateUncertainty: null,
elevation: null,
georeferencingMethod: null,
latitudeDecimal: null,
latitudeDegrees: null,
locationDescription: null,
longitudeDecimal: null,
longitudeDegrees: null,
spatialReferenceSystem: null,
};
const gnpisDonor: Donor = { const gnpisDonor: Donor = {
donorInstitute: gnpisInstitute, donorInstitute: gnpisInstitute,
donorGermplasmPUI: '12', donorGermplasmPUI: '12',
...@@ -181,6 +220,57 @@ describe('GermplasmCardComponent', () => { ...@@ -181,6 +220,57 @@ describe('GermplasmCardComponent', () => {
'schema:includedInDataCatalog': source 'schema:includedInDataCatalog': source
}; };
const germplasmMcpdTest: BrapiGermplasmMcpd = {
groupId: '0',
accessionNames: ['test accession'],
accessionNumber: '01',
acquisitionDate: '2021',
acquisitionSourceCode: 'FR-urgi',
alternateIDs: ['Id1', 'Id2'],
ancestralData: null,
biologicalStatusOfAccessionCode: 'maintained',
breedingInstitutes: brapiInstitute,
collectingInfo: {
collectingDate: '2021',
collectingInstitutes: brapiInstitute,
collectingMissionIdentifier: '007',
collectingNumber: '3',
collectors: 'urgi',
materialType: 'germplasm',
collectingSite: collectingSite,
},
commonCropName: 'wheat',
countryOfOriginCode: 'FR',
donorInfo: {
donorAccessionNumber: 'ING007',
donorInstitute: brapiInstitute,
donationDate: '2021',
},
genus: 'Triti',
germplasmDbId: 'Fr-007',
germplasmPUI: 'urn/fr-007',
instituteCode: 'FR-INRAE',
mlsStatus: '0',
remarks: null,
safetyDuplicateInstitutes: null,
species: 'Triti',
speciesAuthority: null,
storageTypeCodes: null,
subtaxon: null,
subtaxonAuthority: null,
breederAccessionNumber: null,
breedingCreationYear: null,
catalogRegistrationYear: null,
catalogDeregistrationYear: null,
originLocationDbId: 'FR-Ver',
originLocationName: 'Versailles',
holdingInstitute: brapiInstitute,
holdingGenbank: brapiInstitute,
geneticNature: 'hybrid',
presenceStatus: null,
distributorInfos: null
};
const gnpisService = jasmine.createSpyObj( const gnpisService = jasmine.createSpyObj(
'GnpisService', [ 'GnpisService', [
'getGermplasm', 'getGermplasm',
...@@ -194,12 +284,14 @@ describe('GermplasmCardComponent', () => { ...@@ -194,12 +284,14 @@ describe('GermplasmCardComponent', () => {
'BrapiService', [ 'BrapiService', [
// 'germplasmProgeny', // 'germplasmProgeny',
'germplasmPedigree', 'germplasmPedigree',
'germplasmAttributes' 'germplasmAttributes',
'germplasmMcpd'
] ]
); );
// brapiService.germplasmProgeny.and.returnValue(of(brapiGermplasmProgeny)); // brapiService.germplasmProgeny.and.returnValue(of(brapiGermplasmProgeny));
brapiService.germplasmPedigree.and.returnValue(of(brapiGermplasmPedigree)); brapiService.germplasmPedigree.and.returnValue(of(brapiGermplasmPedigree));
brapiService.germplasmAttributes.and.returnValue(of(brapiGermplasmAttributes)); brapiService.germplasmAttributes.and.returnValue(of(brapiGermplasmAttributes));
brapiService.germplasmMcpd.and.returnValue(of(germplasmMcpdTest));
const activatedRouteParams = { const activatedRouteParams = {
......
...@@ -194,19 +194,7 @@ export interface BrapiGermplasmMcpd extends BrapiHasDocumentationURL { ...@@ -194,19 +194,7 @@ export interface BrapiGermplasmMcpd extends BrapiHasDocumentationURL {
collectingNumber: string; collectingNumber: string;
collectors: string; collectors: string;
materialType: string; materialType: string;
collectingSite: { collectingSite: BrapiCollectingSite
locationDbId: string;
locationName: string;
coordinateUncertainty: string;
elevation: string;
georeferencingMethod: string;
latitudeDecimal: string;
latitudeDegrees: string;
locationDescription: string;
longitudeDecimal: string;
longitudeDegrees: string;
spatialReferenceSystem: string;
};
}; };
commonCropName: string; commonCropName: string;
countryOfOriginCode: string; countryOfOriginCode: string;
...@@ -258,6 +246,20 @@ export interface BrapiInstitute { ...@@ -258,6 +246,20 @@ export interface BrapiInstitute {
logo: string; logo: string;
} }
export interface BrapiCollectingSite {
locationDbId: string;
locationName: string;
coordinateUncertainty: string;
elevation: string;
georeferencingMethod: string;
latitudeDecimal: string;
latitudeDegrees: string;
locationDescription: string;
longitudeDecimal: string;
longitudeDegrees: string;
spatialReferenceSystem: string;
}
export interface BrapiTaxonIds { export interface BrapiTaxonIds {
sourceName: string; sourceName: string;
......
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