@Test public void testGetSetterVcCommandsTooLongSingleQuote() { final String xChunk = StringUtils.repeat("x", 129); final String recordName = "record"; final String fieldName = "vc_field"; final int maxCharLength = 132 - ("set " + recordName + "->" + fieldName + " = concat('',\"'\",'')").length(); final String data = StringUtils.repeat("x", maxCharLength - 2) + "'x" + xChunk + xChunk + "x"; 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); final String singleDataChunk = StringUtils.repeat("x", maxCharLength); int index = 0; assertThat(commands.get(index++)).isEqualTo("set " + recordName + "->" + fieldName + " = "); assertThat(commands.get(index++)).isEqualTo("concat("); assertThat(commands.get(index++)).isEqualTo("concat("); assertThat(commands.get(index++)) .isEqualTo("'" + singleDataChunk.substring(0, singleDataChunk.length() - 2) + "'"); assertThat(commands.get(index++)).isEqualTo(", \"'\""); assertThat(commands.get(index++)).isEqualTo(", 'x'"); assertThat(commands.get(index++)).isEqualTo(")"); assertThat(commands.get(index++)).isEqualTo(","); assertThat(commands.get(index++)).isEqualTo("'" + xChunk + "'"); assertThat(commands.get(index++)).isEqualTo(","); assertThat(commands.get(index++)).isEqualTo("'" + xChunk + "'"); assertThat(commands.get(index++)).isEqualTo(","); assertThat(commands.get(index++)).isEqualTo("'x'"); assertThat(commands.get(index++)).isEqualTo(")"); assertThat(commands.get(index++)).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);  }