use of org.molgenis.js.magma.JsMagmaScriptEvaluator in project molgenis by molgenis.
the class JsMagmaScriptEvaluatorTest method beforeClass.
@BeforeClass
protected static void beforeClass() {
Attribute idAttribute = mock(Attribute.class);
when(idAttribute.getName()).thenReturn("id");
when(idAttribute.getDataType()).thenReturn(STRING);
Attribute weightAttr = when(mock(Attribute.class).getName()).thenReturn("weight").getMock();
when(weightAttr.getDataType()).thenReturn(INT);
personWeightEntityType = when(mock(EntityType.class).getId()).thenReturn("person").getMock();
when(personWeightEntityType.getIdAttribute()).thenReturn(idAttribute);
when(personWeightEntityType.getAttribute("weight")).thenReturn(weightAttr);
when(personWeightEntityType.getAtomicAttributes()).thenReturn(singletonList(weightAttr));
Attribute heightAttr = when(mock(Attribute.class).getName()).thenReturn("height").getMock();
when(heightAttr.getDataType()).thenReturn(INT);
personHeightEntityType = when(mock(EntityType.class).getId()).thenReturn("person").getMock();
when(personHeightEntityType.getIdAttribute()).thenReturn(idAttribute);
when(personHeightEntityType.getAttribute("height")).thenReturn(heightAttr);
when(personHeightEntityType.getAtomicAttributes()).thenReturn(singletonList(heightAttr));
personWeightAndHeightEntityType = when(mock(EntityType.class).getId()).thenReturn("person").getMock();
when(personWeightAndHeightEntityType.getIdAttribute()).thenReturn(idAttribute);
when(personWeightAndHeightEntityType.getAttribute("weight")).thenReturn(weightAttr);
when(personWeightAndHeightEntityType.getAttribute("height")).thenReturn(heightAttr);
when(personWeightAndHeightEntityType.getAtomicAttributes()).thenReturn(asList(weightAttr, heightAttr));
Attribute birthDateAttr = when(mock(Attribute.class).getName()).thenReturn("birthdate").getMock();
when(birthDateAttr.getDataType()).thenReturn(DATE);
personBirthDateMeta = when(mock(EntityType.class).getId()).thenReturn("person").getMock();
when(personBirthDateMeta.getIdAttribute()).thenReturn(idAttribute);
when(personBirthDateMeta.getAttribute("birthdate")).thenReturn(birthDateAttr);
when(personBirthDateMeta.getAtomicAttributes()).thenReturn(singletonList(birthDateAttr));
Attribute ageAttr = when(mock(Attribute.class).getName()).thenReturn("age").getMock();
when(ageAttr.getDataType()).thenReturn(INT);
personAgeEntityType = when(mock(EntityType.class).getId()).thenReturn("person").getMock();
when(personAgeEntityType.getIdAttribute()).thenReturn(idAttribute);
when(personAgeEntityType.getAttribute("age")).thenReturn(ageAttr);
when(personAgeEntityType.getAtomicAttributes()).thenReturn(singletonList(ageAttr));
Attribute genderAttr = when(mock(Attribute.class).getName()).thenReturn("gender").getMock();
when(genderAttr.getDataType()).thenReturn(CATEGORICAL);
personGenderEntityType = when(mock(EntityType.class).getId()).thenReturn("person").getMock();
when(personGenderEntityType.getIdAttribute()).thenReturn(idAttribute);
when(personGenderEntityType.getAttribute("gender")).thenReturn(genderAttr);
when(personGenderEntityType.getAtomicAttributes()).thenReturn(singletonList(genderAttr));
Attribute labelAttr = when(mock(Attribute.class).getName()).thenReturn("label").getMock();
when(labelAttr.getDataType()).thenReturn(STRING);
genderEntityType = when(mock(EntityType.class).getId()).thenReturn("gender").getMock();
when(genderEntityType.getIdAttribute()).thenReturn(idAttribute);
when(genderEntityType.getAttribute("id")).thenReturn(idAttribute);
when(genderEntityType.getAttribute("label")).thenReturn(labelAttr);
when(genderEntityType.getAtomicAttributes()).thenReturn(newArrayList(idAttribute, labelAttr));
Attribute traitAttr = when(mock(Attribute.class).getName()).thenReturn("trait").getMock();
when(traitAttr.getDataType()).thenReturn(MREF);
personTraitEntityType = when(mock(EntityType.class).getId()).thenReturn("person").getMock();
when(personTraitEntityType.getIdAttribute()).thenReturn(idAttribute);
when(personTraitEntityType.getAttribute("id")).thenReturn(idAttribute);
when(personTraitEntityType.getAttribute("trait")).thenReturn(traitAttr);
when(personTraitEntityType.getAtomicAttributes()).thenReturn(newArrayList(idAttribute, traitAttr));
Attribute nameAttr = when(mock(Attribute.class).getName()).thenReturn("name").getMock();
when(nameAttr.getDataType()).thenReturn(STRING);
traitEntityType = when(mock(EntityType.class).getId()).thenReturn("trait").getMock();
when(traitEntityType.getIdAttribute()).thenReturn(idAttribute);
when(traitEntityType.getAttribute("id")).thenReturn(idAttribute);
when(traitEntityType.getAttribute("name")).thenReturn(nameAttr);
when(traitEntityType.getAtomicAttributes()).thenReturn(newArrayList(idAttribute, nameAttr));
jsMagmaScriptEvaluator = new JsMagmaScriptEvaluator(new NashornScriptEngine());
}
Aggregations