Skip to content

Commit

Permalink
updated tests and options
Browse files Browse the repository at this point in the history
  • Loading branch information
Guy Davenport committed Nov 14, 2024
1 parent baaed70 commit fe47c1a
Show file tree
Hide file tree
Showing 7 changed files with 322 additions and 168 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = 'org.brapi'
version = '0.11.0-SNAPSHOT'
version = '0.12.0-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ public List<BrAPIObjectProperty> getLinkPropertiesFor(BrAPIObjectType brAPIObjec
return linkProperties ;
}

/**
* Gets the id parameter name for a type
* @param type The BrAPI type
* @return the id parameter name for a type
*/
public String getIdPropertyNameFor(String type) {
return id.getPropertyNameFor(type) ;
}

/**
* Gets the id parameter name for a type
* @param type The BrAPI type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public class ConfigurationUtils {
private static final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());

/**
* Load the configurations from a file in YAML or Json. The file may have missing
* (defined) values, in these cases the default values are loaded.
* Load the configurations from a file in YAML or Json.
* @param configurationsFile The path to the configuration file in YAML or Json.
* @param configurationClass The configuration class.
* @param <T> the class of the configuration
Expand Down Expand Up @@ -45,8 +44,7 @@ public static <T> T load(String classPath, Class<T> configurationClass) throws I
}

/**
* Load the configurations from an input stream in YAML or Json. The configuration file may have missing
* (defined) values, in these cases the default values are loaded.
* Load the configurations from an input stream in YAML or Json.
* @param inputStream The input stream in YAML or Json
* @param configurationClass The configuration class.
* @param <T> the class of the configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ void loadYaml() {
checkOptions(options);
}

@Test
void overwrite() {
GraphQLGeneratorOptions options = null;
try {
options = GraphQLGeneratorOptions.load(Path.of(ClassLoader.getSystemResource("graphql-overwrite-options.yaml").toURI()));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
fail(e.getMessage());
}

checkOptions(options);

assertEquals("attributeDbId", options.getIds().getIDFieldFor("GermplasmAttribute")) ;
assertEquals("attributeDbId", options.getIds().getIDFieldFor("CultivarAttribute")) ;
}

private void checkOptions(GraphQLGeneratorOptions options) {
assertNotNull(options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,171 +53,19 @@ void loadYaml() {
}

@Test
void isGeneratingSingleGet() {
}

@Test
void isGeneratingListGet() {
}

@Test
void isGeneratingSearch() {
}

@Test
void isGeneratingPost() {
}

@Test
void isGeneratingPut() {
}

@Test
void isGeneratingDelete() {
}

@Test
void isGeneratingEndpoint() {
}

@Test
void isGeneratingEndpointWithId() {
}

@Test
void isGeneratingSearchEndpoint() {
}

@Test
void isGeneratingSingleGetEndpointFor() {
}

@Test
void isGeneratingListGetEndpointFor() {
}

@Test
void isGeneratingPostEndpointFor() {
}

@Test
void isGeneratingPutEndpointFor() {
}

@Test
void isGeneratingDeleteEndpointFor() {
}

@Test
void isGeneratingSearchEndpointFor() {
}

@Test
void isGeneratingEndpointFor() {
}

@Test
void isGeneratingEndpointNameWithIdFor() {
}

@Test
void isGeneratingNewRequestFor() {
}

@Test
void getNewRequestNameFor() {
}

@Test
void isGeneratingListResponseFor() {
}

@Test
void getSingleResponseNameFor() {
}

@Test
void getListResponseNameFor() {
}

@Test
void isGeneratingSearchRequestFor() {
}

@Test
void getSearchRequestNameFor() {
}

@Test
void getPluralFor() {
}

@Test
void getSingularForProperty() {
}

@Test
void isSeparatingByModule() {
}

@Test
void getSingleGet() {
}

@Test
void getListGet() {
}

@Test
void getPost() {
}

@Test
void getPut() {
}

@Test
void getDelete() {
}

@Test
void getSearch() {
}

@Test
void getIds() {
}

@Test
void isCreatingNewRequest() {
}

@Test
void getCreatingNewRequestFor() {
}

@Test
void getNewRequestNameFormat() {
}

@Test
void getSingleResponseNameFormat() {
}

@Test
void getListResponseNameFormat() {
}

@Test
void getSearchRequestNameFormat() {
}
void overwrite() {
OpenAPIGeneratorOptions options = null;
try {
options = OpenAPIGeneratorOptions.load(Path.of(ClassLoader.getSystemResource("openapi-overwrite-options.yaml").toURI()));
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
fail(e.getMessage());
}

@Test
void builder() {
}
checkOptions(options);

@Test
void toBuilder() {
assertEquals("attributeDbId", options.getProperties().getIdPropertyNameFor("GermplasmAttribute")) ;
assertEquals("attributeDbId", options.getProperties().getIdPropertyNameFor("CultivarAttribute")) ;
}

private void checkOptions(OpenAPIGeneratorOptions options) {
Expand Down
124 changes: 124 additions & 0 deletions java/core/src/test/resources/graphql-overwrite-options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
pluralFor:
AlleleMatrix: AlleleMatrix
ids:
useIDType: true
nameFormat: "%sDbId"
fieldFor:
CultivarAttribute: attributeDbId
CultivarAttributeValue: attributeValueDbId
GermplasmAttribute: attributeDbId
GermplasmAttributeValue: attributeValueDbId
LocaleAttribute: attributeDbId
LocaleAttributeValue: attributeValueDbId
ObservationUnitAttribute: attributeDbId
ObservationUnitAttributeValue: attributeValueDbId
SeedLotAttribute: attributeDbId
SeedLotAttributeValue: attributeValueDbId
input:
name: input
nameFormat: "%sInput"
typeNameFormat: "%sInput"
queryType:
name: Query
partitionedByCrop: true
singleQuery:
generate: true
pluralisingName: false
nameFormat: "%s"
descriptionFormat: Returns a %s object by id
generateFor:
AlleleMatrix: false
Call: false
Cross: false
Event: false
MarkerPosition: false
PlannedCross: false
listQuery:
generate: true
pluralisingName: true
nameFormat: "%s"
descriptionFormat: Returns %s objects
responseTypeNameFormat: "%sListResponse"
dataFieldName: data
pagedDefault: true
paged:
BreedingMethod: false
input:
BreedingMethod: false
CrossingProject: true
generateFor:
AlleleMatrix: false
pagingInputName: paging
pageInputTypeName: PageInput
pageTypeName: PageInfo
pageFieldName: page
searchQuery:
generate: true
pluralisingName: true
nameFormat: "%sSearch"
descriptionFormat: Returns %s objects
responseTypeNameFormat: "%sResponse"
searchIdFieldName: searchResultsDbId
generateFor:
AlleleMatrix: false
BreedingMethod: false
Cross: false
CrossProject: false
Method: false
Ontology: false
Scale: false
Trait: false
mutationType:
name: Mutation
createMutation:
generate: true
pluralisingName: false
nameFormat: create%s
descriptionFormat: Create a new %s
generateFor:
AlleleMatrix: false
Call: false
CallSet: false
Cross: false
Event: false
GenomeMap: false
MarkerPosition: false
PedigreeNode: false
Reference: false
Variant: false
updateMutation:
generate: true
pluralisingName: false
nameFormat: update%s
descriptionFormat: Update the details for an existing %s
generateFor:
AlleleMatrix: false
Call: false
CallSet: false
Cross: false
Event: false
GenomeMap: false
MarkerPosition: false
PedigreeNode: false
Reference: false
Variant: false
deleteMutation:
generate: false
pluralisingName: true
multiple: true
nameFormat: delete%s
descriptionFormat: Delete existing %s
generateFor:
AlleleMatrix: false
Call: false
CallSet: false
Event: false
GenomeMap: false
MarkerPosition: false
PedigreeNode: false
Reference: false
Variant: false
VariantSet: false
mergeOneOfType: true
mergingOneOfTypeFor:
GeoJSONGeometry: false
Loading

0 comments on commit fe47c1a

Please sign in to comment.