TableTypeImpl implements TableType { @Override public FieldType findFieldBy(final FieldTypeReference fieldRef) { return lookupByDef.get(fieldRef); } TableTypeImpl(final String name, final List<FieldType> fields);  TableTypeImpl(final String name, final FieldType... fields); @Override String getName(); @Override List<FieldType> getFields(); @Override FieldType findFieldBy(final FieldTypeReference fieldRef); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void findStructureByDefOfExisting_should_returnStructure() { final DataType integer = DataType.INTEGER; final FieldDef origin = Daleq.fd(integer).name("propertyDef"); final FieldType fieldType = new FieldTypeImpl( "P NAME", integer, Optional.<TemplateValue>of(new StringTemplateValue("bar")), origin ); final TableType table = new TableTypeImpl("SOME_NAME", fieldType); assertThat(table.findFieldBy(origin), is(fieldType)); }
@Test public void findStructureByDefOfNonExisting_should_notReturnStructure() { final FieldDef origin = Daleq.fd(DataType.INTEGER).name("propertyDef"); final TableType table = new TableTypeImpl("SOME_NAME"); assertThat(table.findFieldBy(origin), is(nullValue())); }