LhsBuilder implements SourceBuilder { public FieldType calcFieldType( String content ) { final SnippetBuilder.SnippetType snippetType = SnippetBuilder.getType( content ); if ( snippetType.equals( SnippetBuilder.SnippetType.FORALL ) ) { return FieldType.FORALL_FIELD; } else if ( !snippetType.equals( SnippetBuilder.SnippetType.SINGLE ) ) { return FieldType.NORMAL_FIELD; } for ( String op : operators ) { if ( content.endsWith( op ) ) { return FieldType.OPERATOR_FIELD; } } return FieldType.SINGLE_FIELD; } LhsBuilder( int row,
                       int column,
                       String colDefinition ); ActionType.Code getActionTypeCode(); void addTemplate( int row,
                             int column,
                             String content ); void clearValues(); void addCellValue( int row, int column, String value); void addCellValue( int row, int column, String value, boolean trim); String getResult(); FieldType calcFieldType( String content ); boolean hasValues(); int getColumn();  }
@Test public void testIdentifyFieldTypes() { LhsBuilder builder = new LhsBuilder( 9, 1, "" ); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("age")); assertEquals(FieldType.OPERATOR_FIELD, builder.calcFieldType("age <")); assertEquals(FieldType.NORMAL_FIELD, builder.calcFieldType("age < $param")); assertEquals(FieldType.FORALL_FIELD, builder.calcFieldType("forall(||){age < $}")); assertEquals(FieldType.FORALL_FIELD, builder.calcFieldType("forall(&&){age < $}")); assertEquals(FieldType.FORALL_FIELD, builder.calcFieldType("forall(,){age < $}")); assertEquals(FieldType.FORALL_FIELD, builder.calcFieldType("forall(){age < $}")); assertEquals(FieldType.FORALL_FIELD, builder.calcFieldType("forall(){age < $} && forall(){age == $}")); assertEquals(FieldType.FORALL_FIELD, builder.calcFieldType("x && forall(){age < $} && forall(){age == $}")); assertEquals(FieldType.FORALL_FIELD, builder.calcFieldType("x && forall(){age < $} && forall(){age == $} && y")); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("age < $para")); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("forall{||}{age < $}")); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("forall(){}")); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("forall(){age < $")); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("forall(){,")); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("forall({})")); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("forall({}){test})")); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("forall(&&){{}})")); assertEquals(FieldType.SINGLE_FIELD, builder.calcFieldType("forall(&&){{})")); }