Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-gary committed Jan 16, 2025
1 parent 77fcaac commit 2563d25
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected void postLoadMetamodel() {
// Get the complete metadata map - if I get only get current application, client transfer objects does not get
// generated with parent references
Map<String, Record> recordMap = getTargetMetadataMap();
recordMapIterator = (recordMap != null) ? recordMap.values().iterator() : Collections.emptyIterator();
recordMapIterator = recordMap.values().iterator();
while (recordMapIterator.hasNext()) {
record = (RecordElement) recordMapIterator.next();
relationMap = record.getRelations();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.fasterxml.jackson.annotation.JsonValue;
import org.apache.commons.lang3.StringUtils;
import org.technologybrewery.fermenter.mda.metamodel.element.Validatable;
import org.technologybrewery.fermenter.mda.metamodel.element.Field;
//import org.technologybrewery.fermenter.mda.metamodel.element.Field;
import org.technologybrewery.fermenter.mda.metamodel.element.NamespacedMetamodel;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public void validate() {
/**
* Sets the relation type package.
*
* @param package
* relation type package
* @param packageName
* relation type packageName
*/
public void setPackage(String packageName) {
this.packageName = packageName;
Expand Down Expand Up @@ -132,7 +132,7 @@ public void setDocumentation(String documentation) {
public void setMultiplicity(String multiplicityAsString) {
this.multiplicity = Multiplicity.fromString(multiplicityAsString);

if (StringUtils.isNoneBlank(multiplicityAsString) && multiplicity == null) {
if (StringUtils.isNotBlank(multiplicityAsString) && multiplicity == null) {
messageTracker.addErrorMessage("Could not map multiplicity '" + multiplicityAsString
+ "' to one of the known multiplicity types! (" + Multiplicity.options() + ") ");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public List<RecordField> getFields() {
if (fieldType.isDictionaryTyped()) {
fields.add(sparkField);
} else {
logger.warn("Spark schema does not support non-dictionary type - skip adding field '{}' to Spark schema.",
sparkField.getName());
throw new IllegalArgumentException("Field type must be of type Dictionary");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
}
},
"required": [
"name","type"
"name","package"
]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.apache.commons.lang3.RandomStringUtils;
import org.technologybrewery.fermenter.mda.metamodel.element.FieldElement;
//import org.apache.commons.lang3.RandomStringUtils;
//import org.technologybrewery.fermenter.mda.metamodel.element.FieldElement;

public class RecordSteps extends AbstractModelInstanceSteps {

Expand Down Expand Up @@ -421,24 +421,19 @@ public void theRecordIsAvailableAndHasPysparkSupportDisabled() {
assertFalse("Record does not contain the pyspark framework", found.isPresent());
}

@Given("record A")
public void record_a() {
// Record A will be created with a relation to Record B after Record B is created
}

@Given("record B")
public void record_b() {
RecordElement newRecord = createNewRecordWithNameAndPackage("RecordB", RELATION_PACKAGE);
RecordFieldElement field = new RecordFieldElement();
field.setName("FieldB");
RecordFieldTypeElement type = new RecordFieldTypeElement();
type.setName("serial_num");
type.setName("phoneNumber");
field.setType(type);
newRecord.addField(field);
saveRecordToFile(newRecord);
}

@Given("record A references record B")
@Given("record A has a relation to record B")
public void record_a_references_record_b() throws IOException {
RelationInput relationInput = new RelationInput();
relationInput.type = "RecordB";
Expand All @@ -447,6 +442,17 @@ public void record_a_references_record_b() throws IOException {
createRecordWithRelation("RecordA", TEST_RECORD_RELATIONS, relationInput);
}

/**
* Uses to pass relation-level information into test steps
*/
private static class RelationInput {
public String documentation;
public String type;
public String relationPackage;
public String multiplicity;
public String localColumn;
}

@Then("the records are successfully created")
public void the_records_are_successfully_created() {
Record ARecord = this.metadataRepo.getRecord(TEST_RECORD_RELATIONS,"RecordA");
Expand Down Expand Up @@ -474,17 +480,6 @@ public void you_can_reference_record_a_from_record_b() {
BRecordInverseRelations.get(0).getTitle().equalsIgnoreCase("RecordA"));
}

/**
* Uses to pass relation-level information into test steps
*/
public static class RelationInput {
public String documentation;
public String type;
public String relationPackage;
public String multiplicity;
public String localColumn;
}

private RecordElement createRecordWithRelation(String name, String packageName, RelationInput relation)
throws IOException {
RecordElement newRecord = createNewRecordWithNameAndPackage(name, packageName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Feature: Specify record of semantically defined types
| archivable | boolean | | | sampleMinimumPolicy |
| gender | string | | | genderDistributionPolicy |
| binarydata | byte[] | | | |
| serial_num | string | | | |

Scenario Outline: Create a valid record file
Given a record described by "<name>", "<package>"
Expand Down Expand Up @@ -203,9 +202,8 @@ Feature: Specify record of semantically defined types
Then the record is available and has Pyspark support disabled

Scenario: A record can reference another record as a field
Given record A
Given record B
Given record A references record B
Given record A has a relation to record B
When records are read
Then the records are successfully created
And you can reference record B from record A
Expand Down

0 comments on commit 2563d25

Please sign in to comment.