Commit 913f2bb6 authored by Matija Obreza's avatar Matija Obreza

Removed Manager calls

parent e9e8126c
/*
* Copyright 2017 Global Crop Diversity Trust
*
* 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.genesys.glis.v1.api;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.genesys.glis.v1.invoker.ApiException;
import org.genesys.glis.v1.model.Acquisition;
import org.genesys.glis.v1.model.Actor;
import org.genesys.glis.v1.model.Collection;
import org.genesys.glis.v1.model.Collector;
import org.genesys.glis.v1.model.Location;
import org.genesys.glis.v1.model.Registration;
import org.genesys.glis.v1.model.RegistrationResponse;
import org.genesys.glis.v1.model.Relationship;
import org.junit.Ignore;
import org.junit.Test;
/**
* API tests for ManagerApi
*/
@Ignore
public class RegistrationApiTest extends BaseApiTest {
private final ManagerApi api = new ManagerApi(defaultClient);
/**
* Register PGRFA in GLIS
*
* @throws ApiException if the Api call fails
*/
@Test
public void registerPGRFA() throws ApiException {
Registration pgrfa = makePGRFA("Matija", "Matija ");
RegistrationResponse response = api.registerPGRFA(pgrfa);
assertThat(response.getError(), is(nullValue()));
assertThat(response.getSampleid(), is(pgrfa.getSampleid()));
assertThat(response.getGenus(), is(pgrfa.getGenus()));
assertThat(response.getDoi(), not(nullValue()));
assertTrue("GLIS did not return a valid DOI", response.getDoi().matches(GLIS_DOI_PATTERN));
}
public Registration makePGRFA(String cropName, String prefix) {
Registration pgrfa = new Registration();
pgrfa.setUsername(GLIS_USERNAME);
pgrfa.setPassword(GLIS_PASSWORD);
SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd");
pgrfa.setDate(df.format(new Date()));
pgrfa.addCropnamesItem(cropName);
pgrfa.setSampleid(prefix + System.currentTimeMillis());
pgrfa.setMethod("obna");
Location location = new Location();
location.setWiews("NLD037");
pgrfa.setLocation(location);
return pgrfa;
}
@Test
public void relsTest() throws ApiException {
Registration pgrfa1 = makePGRFA("Matija", "Matija ");
RegistrationResponse response1 = api.registerPGRFA(pgrfa1);
assertThat(response1.getDoi(), not(nullValue()));
Registration pgrfa2 = makePGRFA("Matija", "Matija ").method("nodi");
pgrfa2.addProgdoiItem(response1.getDoi()).addProgdoiItem(response1.getDoi());
RegistrationResponse response2 = api.registerPGRFA(pgrfa2);
assertThat(response2.getDoi(), not(nullValue()));
List<Relationship> rels = queryApi.listRelationships(response1.getDoi(), null, null);
assertThat(rels.size(), greaterThan(0));
}
@Test
public void testAcquisition() throws ApiException {
Registration pgrfa = makePGRFA("Matija", "Matija ").method("acqu").acquisition(new Acquisition().provenance("SVN").provider(new Actor().name("Genesys GLIS Tool").country("DEU")))
.date("2017-07-23");
RegistrationResponse response = api.registerPGRFA(pgrfa);
assertThat(response.getDoi(), not(nullValue()));
}
@Test
public void testCollection() throws ApiException {
Registration pgrfa = makePGRFA("Matija", "Matija ").method("acqu").collection(new Collection().date("2017-07-23").elevation(100).missid("Genesys GLIS"));
RegistrationResponse response = api.registerPGRFA(pgrfa);
assertThat(response.getDoi(), not(nullValue()));
}
@Test
public void testCollectionCollector() throws ApiException {
Registration pgrfa = makePGRFA("Matija", "Matija ").method("acqu")
.collection(new Collection().date("2017-07-23").elevation(100).missid("Genesys GLIS").addCollectorsItem(new Collector().name("Matija Obreza").country("SVN")));
RegistrationResponse response = api.registerPGRFA(pgrfa);
assertThat(response.getDoi(), not(nullValue()));
}
}
/*
* Copyright 2017 Global Crop Diversity Trust
*
* 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.genesys.glis.v1.api;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import org.genesys.glis.v1.invoker.ApiException;
import org.genesys.glis.v1.model.Registration;
import org.genesys.glis.v1.model.RegistrationResponse;
import org.junit.Ignore;
import org.junit.Test;
/**
* API tests for ManagerApi
*/
@Ignore
public class RegistrationApiTest extends BaseApiTest {
private final ManagerApi api = new ManagerApi(defaultClient);
/**
* Register PGRFA in GLIS
* FIXME TODO https://github.com/swagger-api/swagger-codegen/issues/3870
* @throws ApiException if the Api call fails
*/
@Test
@Ignore("https://github.com/swagger-api/swagger-codegen/issues/3870")
public void registerPGRFA() throws ApiException {
Registration pgrfa= new Registration();
pgrfa.setUsername(GLIS_USERNAME);
pgrfa.setPassword(GLIS_PASSWORD);
RegistrationResponse response = api.registerPGRFA(pgrfa);
assertThat(response.getError(), hasSize(0));
assertThat(response.getSampleid(), is(pgrfa.getSampleid()));
assertThat(response.getGenus(), is(pgrfa.getGenus()));
}
}
......@@ -31,7 +31,7 @@
<invokerPackage>org.genesys.glis.v1.invoker</invokerPackage>
<output>${generated-sources-path}</output>
<configOptions>
<withXml>true</withXml>
<withXml>false</withXml>
<java8>true</java8>
<dateLibrary>java8</dateLibrary>
<sourceFolder>${generated-sources-java-path}</sourceFolder>
......
/*
* Copyright 2017 Global Crop Diversity Trust
*
* 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.genesys.glis.v1.api;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import org.genesys.glis.v1.invoker.ApiException;
import org.genesys.glis.v1.model.Registration;
import org.genesys.glis.v1.model.RegistrationResponse;
import org.junit.Ignore;
import org.junit.Test;
/**
* API tests for ManagerApi
*/
@Ignore
public class RegistrationApiTest extends BaseApiTest {
private final ManagerApi api = new ManagerApi(defaultClient);
/**
* Register PGRFA in GLIS
* FIXME TODO https://github.com/swagger-api/swagger-codegen/issues/3870
* @throws ApiException if the Api call fails
*/
@Test
@Ignore("https://github.com/swagger-api/swagger-codegen/issues/3870")
public void registerPGRFA() throws ApiException {
Registration pgrfa= new Registration();
pgrfa.setUsername(GLIS_USERNAME);
pgrfa.setPassword(GLIS_PASSWORD);
RegistrationResponse response = api.registerPGRFA(pgrfa);
assertThat(response.getError(), hasSize(0));
assertThat(response.getSampleid(), is(pgrfa.getSampleid()));
assertThat(response.getGenus(), is(pgrfa.getGenus()));
}
}
/*
* Copyright 2017 Global Crop Diversity Trust
*
* 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.genesys.glis.v1.api;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.genesys.glis.v1.model.Location;
import org.genesys.glis.v1.model.Registration;
import org.genesys.glis.v1.model.RegistrationResponse;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.client.HttpClientErrorException;
/**
* API tests for ManagerApi
*/
@Ignore
public class RegistrationApiTest extends BaseApiTest {
private final ManagerApi api = new ManagerApi(defaultClient);
@Test
public void serializationTest() throws JsonProcessingException {
Registration pgrfa = new Registration();
pgrfa.setUsername("dummy");
pgrfa.setPassword("passwd");
SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd");
pgrfa.setDate(df.format(new Date()));
// pgrfa.setDate("1990");
pgrfa.addCropnamesItem("Matija");
pgrfa.setSampleid("Matija " + System.currentTimeMillis());
pgrfa.setMethod("ihcp");
Location location = new Location();
location.setWiews("NLD037");
pgrfa.setLocation(location);
System.err.println(pgrfa.toString());
System.err.println(xmlMapper.writeValueAsString(pgrfa));
}
@Test
public void testAuthorizationResponse() throws Exception {
Registration pgrfa = new Registration();
pgrfa.setUsername("dummy");
pgrfa.setPassword("passwd");
try {
RegistrationResponse response = api.registerPGRFA(pgrfa);
// should not happen
throw new Exception("Invalid server response received: " + response);
} catch (HttpClientErrorException e) {
assertThat(e.getStatusCode(), is(HttpStatus.FORBIDDEN));
assertTrue(e.getResponseHeaders().getContentType().isCompatibleWith(MediaType.APPLICATION_XML));
}
}
/**
* Register PGRFA in GLIS FIXME TODO https://github.com/swagger-api/swagger-codegen/issues/3870
*
* @throws ApiException if the Api call fails
*/
@Test
public void registerPGRFA() {
Registration pgrfa = new Registration();
pgrfa.setUsername(GLIS_USERNAME);
pgrfa.setPassword(GLIS_PASSWORD);
SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd");
pgrfa.setDate(df.format(new Date()));
// pgrfa.setDate("1990-03-22");
pgrfa.addCropnamesItem("Matija");
pgrfa.setSampleid("Matija " + System.currentTimeMillis());
pgrfa.setMethod("ihcp");
Location location = new Location();
location.setWiews("NLD037");
pgrfa.setLocation(location);
RegistrationResponse response = api.registerPGRFA(pgrfa);
System.out.println("Response: " + response.toString());
assertThat(response.getError(), is(nullValue()));
assertThat(response.getSampleid(), is(pgrfa.getSampleid()));
assertThat(response.getGenus(), is(pgrfa.getGenus()));
assertThat(response.getDoi(), not(nullValue()));
assertTrue("GLIS did not return a valid DOI", response.getDoi().matches(BaseApiTest.GLIS_DOI_PATTERN));
}
@Test
public void dummyDoiTest() {
assertTrue("10.0155/2HZ~".matches(BaseApiTest.GLIS_DOI_PATTERN));
assertTrue("10.0155/2J0$".matches(BaseApiTest.GLIS_DOI_PATTERN));
assertTrue("10.0155/2J30".matches(BaseApiTest.GLIS_DOI_PATTERN));
}
}
......@@ -18,7 +18,7 @@ swagger: '2.0'
info:
description: >-
Genesys API client to the Global Information System (GLIS) for PGRFA [https://glis.planttreaty.org](https://glis.planttreaty.org).
version: 1.0.0
version: '1.0-SNAPSHOT'
title: Global Information System API Client
termsOfService: 'https://glis.planttreaty.org/terms/'
contact:
......@@ -72,74 +72,74 @@ tags:
externalDocs:
description: Find out more
url: 'https://glis.planttreaty.org'
- name: manager
description: Manage PGRFA in GLIS
externalDocs:
description: Global Information System XML integration protocol
url: 'https://glis.planttreaty.org'
# - name: manager
# description: Manage PGRFA in GLIS
# externalDocs:
# description: Global Information System XML integration protocol
# url: 'https://glis.planttreaty.org'
paths:
/glis/xml/register:
post:
tags:
- manager
summary: Register PGRFA in GLIS and (potentially) obtain GLIS-minted DOI
security: []
description: >-
The purpose of this transaction is to obtain a DOI associated to the PGRFA by providing a set of descriptors in the registration request. However, if a DOI obtained through a service other than GLIS is already associated to the PGRFA, it must be provided in the request so that GLIS will not assign a new DOI but just adopt the one provided.
operationId: registerPGRFA
consumes:
# - application/json
- application/xml
produces:
- application/xml
parameters:
- in: body
name: pgrfa
description: Register PGRFA in GLIS and obtain GLIS DOI.
schema:
$ref: '#/definitions/Registration'
responses:
'200':
description: Successful operation
schema:
$ref: '#/definitions/RegistrationResponse'
'400':
description: XML input invalid
schema:
$ref: '#/definitions/ApiError'
'403':
description: Authentication failure
schema:
$ref: '#/definitions/ApiError'
/glis/xml/update:
post:
tags:
- manager
summary: Update PGRFA in GLIS
security: []
description: >-
Update information on PGRFA already registered in GLIS.
operationId: updatePGRFA
consumes:
# - application/json
- application/xml
produces:
- application/xml
parameters:
- in: body
name: pgrfa
description: Update PGRFA in GLIS by DOI.
schema:
$ref: '#/definitions/GLISUpdate'
responses:
'200':
description: Successful operation
schema:
$ref: '#/definitions/RegistrationResponse'
# /glis/xml/register:
# post:
# tags:
# - manager
# summary: Register PGRFA in GLIS and (potentially) obtain GLIS-minted DOI
# security: []
# description: >-
# The purpose of this transaction is to obtain a DOI associated to the PGRFA by providing a set of descriptors in the registration request. However, if a DOI obtained through a service other than GLIS is already associated to the PGRFA, it must be provided in the request so that GLIS will not assign a new DOI but just adopt the one provided.
# operationId: registerPGRFA
# consumes:
# # - application/json
# - application/xml
# produces:
# - application/xml
# parameters:
# - in: body
# name: pgrfa
# description: Register PGRFA in GLIS and obtain GLIS DOI.
# schema:
# $ref: '#/definitions/Registration'
#
# responses:
# '200':
# description: Successful operation
# schema:
# $ref: '#/definitions/RegistrationResponse'
# '400':
# description: XML input invalid
# schema:
# $ref: '#/definitions/ApiError'
# '403':
# description: Authentication failure
# schema:
# $ref: '#/definitions/ApiError'
#
#
# /glis/xml/update:
# post:
# tags:
# - manager
# summary: Update PGRFA in GLIS
# security: []
# description: >-
# Update information on PGRFA already registered in GLIS.
# operationId: updatePGRFA
# consumes:
# # - application/json
# - application/xml
# produces:
# - application/xml
# parameters:
# - in: body
# name: pgrfa
# description: Update PGRFA in GLIS by DOI.
# schema:
# $ref: '#/definitions/GLISUpdate'
#
# responses:
# '200':
# description: Successful operation
# schema:
# $ref: '#/definitions/RegistrationResponse'
/glisapi/v1/pgrfas:
get:
......@@ -1319,4 +1319,3 @@ definitions:
externalDocs:
description: GLIS API documentation
url: 'https://glis.planttreaty.org/assets/'
Markdown is supported
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