@Test public void testGetSetterVcCommandsBarelyTooLong() { final String recordName = "record"; final String fieldName = "vc_field"; final int maxCharLength = 133 - ("set " + recordName + "->" + fieldName + " = concat('',\"'\",'')").length(); final String data = StringUtils.repeat("x", maxCharLength); final Field field = mockField(fieldName, DataType.VC); final Structure struct = mockStructure(field); final Record record = mockRecord(recordName, struct); when(record.getVC(fieldName)).thenReturn(data); final List<String> commands = RecordSetter.getSetterCommands(record); assertThat(commands.size()).isEqualTo(7); assertThat(commands.get(0)).isEqualTo("set " + recordName + "->" + fieldName + " = "); assertThat(commands.get(1)).isEqualTo("concat("); assertThat(commands.get(2)).isEqualTo( "'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'"); assertThat(commands.get(3)).isEqualTo(","); assertThat(commands.get(4)).isEqualTo("'x'"); assertThat(commands.get(5)).isEqualTo(")"); assertThat(commands.get(6)).isEqualTo("go"); }
public static List<String> getSetterCommands(final Record record) { final List<String> commands = new ArrayList<String>(); final BreadCrumb rootCrumb = new BreadCrumb(record.getName()); for (final Field field : record.getStructure().getFields()) getSetterCommands(rootCrumb, field, record, commands); return commands; }
RecordSetter { public static List<String> getSetterCommands(final Record record) { final List<String> commands = new ArrayList<String>(); final BreadCrumb rootCrumb = new BreadCrumb(record.getName()); for (final Field field : record.getStructure().getFields()) getSetterCommands(rootCrumb, field, record, commands); return commands; } }
RecordSetter { public static List<String> getSetterCommands(final Record record) { final List<String> commands = new ArrayList<String>(); final BreadCrumb rootCrumb = new BreadCrumb(record.getName()); for (final Field field : record.getStructure().getFields()) getSetterCommands(rootCrumb, field, record, commands); return commands; }  }
RecordSetter { public static List<String> getSetterCommands(final Record record) { final List<String> commands = new ArrayList<String>(); final BreadCrumb rootCrumb = new BreadCrumb(record.getName()); for (final Field field : record.getStructure().getFields()) getSetterCommands(rootCrumb, field, record, commands); return commands; }  static List<String> getSetterCommands(final Record record); }
RecordSetter { public static List<String> getSetterCommands(final Record record) { final List<String> commands = new ArrayList<String>(); final BreadCrumb rootCrumb = new BreadCrumb(record.getName()); for (final Field field : record.getStructure().getFields()) getSetterCommands(rootCrumb, field, record, commands); return commands; }  static List<String> getSetterCommands(final Record record);  }