Skip to content

Commit

Permalink
story 959 task-5023: fix tabulation bug - missing close bracket (fino…
Browse files Browse the repository at this point in the history
  • Loading branch information
ja6a-regnosys authored Aug 27, 2024
1 parent db4a877 commit 40b12c3
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ class TabulatorGenerator {
«FieldValue» «resultId» = new «FieldValueImpl»(«scope.getIdentifierOrThrow(attr)», «Optional».ofNullable(«inputParam».get«attr.name.toFirstUpper»())
.map(«lambdaParam» -> «lambdaParam».stream()
.map(«nestedLambdaParam» -> «nestedLambdaParam».getValue())
.collect(«Collectors».toList()));
.collect(«Collectors».toList())));
«ELSE»
«FieldValue» «resultId» = new «FieldValueImpl»(«scope.getIdentifierOrThrow(attr)», «Optional».ofNullable(«inputParam».get«attr.name.toFirstUpper»())
.map(«lambdaParam» -> «lambdaParam».getValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,80 @@ class ConfigurableTypeTabulatorTest {
assertEquals(expected, fooTabulatorCode)
}

@Test
def void shouldGenerateTabulatorsForTypeEngineSpecificationConfig() {
val model2 = '''
namespace model2
metaType scheme string
type Root:
engineSpecification EngineSpecification (1..1)
type EngineSpecification:
fuel string (1..*)
[metadata scheme]
'''

val model2Code = model2.generateCodeForModel(Model2FileConfigProvider)
val engineSpecificationTabulatorCode = model2Code.get("model2.tabulator.EngineSpecificationTypeTabulator")
assertThat(engineSpecificationTabulatorCode, CoreMatchers.notNullValue())
var expected = '''
package model2.tabulator;
import com.google.inject.ImplementedBy;
import com.rosetta.model.lib.reports.Tabulator;
import com.rosetta.model.lib.reports.Tabulator.Field;
import com.rosetta.model.lib.reports.Tabulator.FieldImpl;
import com.rosetta.model.lib.reports.Tabulator.FieldValue;
import com.rosetta.model.lib.reports.Tabulator.FieldValueImpl;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import model2.EngineSpecification;
@ImplementedBy(EngineSpecificationTypeTabulator.Impl.class)
public interface EngineSpecificationTypeTabulator extends Tabulator<EngineSpecification> {
public class Impl implements EngineSpecificationTypeTabulator {
private final Field fuelField;
public Impl() {
this.fuelField = new FieldImpl(
"fuel",
true,
Optional.empty(),
Optional.empty(),
Arrays.asList()
);
}
@Override
public List<FieldValue> tabulate(EngineSpecification input) {
FieldValue fuel = new FieldValueImpl(fuelField, Optional.ofNullable(input.getFuel())
.map(x -> x.stream()
.map(_x -> _x.getValue())
.collect(Collectors.toList())));
return Arrays.asList(
fuel
);
}
}
}
'''
assertEquals(expected, engineSpecificationTabulatorCode)
}

private static class Model1FileConfigProvider extends RosettaConfigurationFileProvider {
override URL get() {
Thread.currentThread.contextClassLoader.getResource("rosetta-tabulator-type-config-model1.yml")
}
}

private static class Model2FileConfigProvider extends RosettaConfigurationFileProvider {
override URL get() {
Thread.currentThread.contextClassLoader.getResource("rosetta-tabulator-type-config-model2.yml")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
model:
name: My test model
dependencies:
generators:
namespaces:
- model2.*
tabulators:
annotations:
types:
- model2.Root

0 comments on commit 40b12c3

Please sign in to comment.