Skip to content

Commit

Permalink
fixes #126, #127, #128. Dependent on #199
Browse files Browse the repository at this point in the history
  • Loading branch information
BrapiCoordinatorSelby committed Aug 17, 2023
1 parent 1960393 commit 0e46ced
Show file tree
Hide file tree
Showing 4 changed files with 377 additions and 301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,29 @@
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(fluent=true)
@Accessors(fluent = true)
public class PlannedCrossQueryParams extends BrAPIQueryParams {

private String crossingProjectDbId;
private String plannedCrossDbId;
private String externalReferenceSource;
private String externalReferenceId;
@Deprecated
private String externalReferenceID;

public String getExternalReferenceId() {
private String commonCropName;
private String crossingProjectDbId;
private String crossingProjectName;
private String externalReferenceId;
@Deprecated
private String externalReferenceID;
private String externalReferenceSource;
private String plannedCrossDbId;
private String plannedCrossName;
private String programDbId;
private String status;

public String getExternalReferenceId() {
return externalReferenceId;
}
public String externalReferenceId() {

public String externalReferenceId() {
return externalReferenceId;
}

public void setExternalReferenceId(String externalReferenceId) {
this.externalReferenceId = externalReferenceId;
}
Expand All @@ -55,10 +62,12 @@ public void setExternalReferenceId(String externalReferenceId) {
public String getExternalReferenceID() {
return externalReferenceID;
}

@Deprecated
public String externalReferenceID() {
return externalReferenceID;
}

@Deprecated
public void setExternalReferenceID(String externalReferenceID) {
this.externalReferenceID = externalReferenceID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.brapi.client.v2.modules.germplasm;

import org.brapi.client.v2.ApiResponse;
import org.brapi.client.v2.BrAPIClientTest;
import org.brapi.client.v2.model.exceptions.ApiException;
import org.brapi.client.v2.model.queryParams.germplasm.CrossQueryParams;
import org.brapi.client.v2.model.queryParams.germplasm.PlannedCrossQueryParams;
Expand All @@ -21,15 +22,21 @@
import org.brapi.v2.model.germ.response.BrAPICrossesListResponse;
import org.brapi.v2.model.germ.response.BrAPIPlannedCrossesListResponse;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;

import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CrossesApiTest {
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class CrossesApiTest extends BrAPIClientTest{

private final CrossesApi api = new CrossesApi();
private final CrossesApi api = new CrossesApi(this.apiClient);

/**
* Get a filtered list of Cross entities
Expand Down Expand Up @@ -99,17 +106,13 @@ public void crossesPutTest() throws ApiException {
*/
@Test
public void plannedcrossesGetTest() throws ApiException {
String crossingProjectDbId = null;
String plannedCrossDbId = null;
String externalReferenceID = null;
String externalReferenceSource = null;
Integer page = null;
Integer pageSize = null;
String plannedCrossDbId = "cross4";

PlannedCrossQueryParams queryParams = new PlannedCrossQueryParams();
PlannedCrossQueryParams queryParams = new PlannedCrossQueryParams().plannedCrossDbId(plannedCrossDbId);
ApiResponse<BrAPIPlannedCrossesListResponse> response = api.plannedcrossesGet(queryParams);

// TODO: test validations
assertEquals(1, response.getBody().getResult().getData().size());
assertEquals(plannedCrossDbId, response.getBody().getResult().getData().get(0).getPlannedCrossDbId());
}
/**
* Create new Planned Cross entities on this server
Expand All @@ -121,13 +124,17 @@ public void plannedcrossesGetTest() throws ApiException {
*/
@Test
public void plannedcrossesPostTest() throws ApiException {
List<BrAPIPlannedCross> body = null;
BrAPIPlannedCross pCross = new BrAPIPlannedCross()
.crossingProjectDbId("crossing_project2")
.plannedCrossName("New Name");
List<BrAPIPlannedCross> body = Arrays.asList(pCross);

IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
ApiResponse<BrAPIPlannedCrossesListResponse> response = api.plannedcrossesPost(body);
});

// TODO: test validations
assertEquals(1, response.getBody().getResult().getData().size());
assertNotNull(response.getBody().getResult().getData().get(0).getPlannedCrossDbId());
assertEquals(pCross.getPlannedCrossName(), response.getBody().getResult().getData().get(0).getPlannedCrossName());
assertEquals(pCross.getCrossingProjectDbId(), response.getBody().getResult().getData().get(0).getCrossingProjectDbId());
}
/**
* Update existing Planned Cross entities on this server
Expand All @@ -139,12 +146,18 @@ public void plannedcrossesPostTest() throws ApiException {
*/
@Test
public void plannedcrossesPutTest() throws ApiException {
Map<String, BrAPIPlannedCross> body = null;
BrAPIPlannedCross pCross = new BrAPIPlannedCross()
.crossingProjectDbId("crossing_project2")
.plannedCrossName("New Name")
.plannedCrossDbId("cross2");
Map<String, BrAPIPlannedCross> body = new HashMap<String, BrAPIPlannedCross>();
body.put("cross2", pCross);

IllegalArgumentException exception = assertThrows(IllegalArgumentException.class, () -> {
ApiResponse<BrAPIPlannedCrossesListResponse> response = api.plannedcrossesPut(body);
});

// TODO: test validations
assertEquals(1, response.getBody().getResult().getData().size());
assertEquals(pCross.getPlannedCrossDbId(), response.getBody().getResult().getData().get(0).getPlannedCrossDbId());
assertEquals(pCross.getPlannedCrossName(), response.getBody().getResult().getData().get(0).getPlannedCrossName());
assertEquals(pCross.getCrossingProjectDbId(), response.getBody().getResult().getData().get(0).getCrossingProjectDbId());
}
}
Loading

0 comments on commit 0e46ced

Please sign in to comment.