@Test public void testGetSetterCommandsFixedList() { final String fieldName = "i2_field"; final String listName = "list_name"; final String recordName = "record_name"; final short firstValue = 123; final short secondValue = 456; final Field listElementField = mockField(fieldName, DataType.I2); final Structure listStructure = mockStructure(listElementField); final Field listField = mockField(listName, DataType.LIST, listStructure); final Structure rootStruct = mockStructure(listField); final Record firstElement = mockRecord(null, listStructure); when(firstElement.getI2(fieldName)).thenReturn(firstValue); final Record secondElement = mockRecord(null, listStructure); when(secondElement.getI2(fieldName)).thenReturn(secondValue); final RecordList recordList = mock(RecordList.class); when(recordList.iterator()).thenReturn(Arrays.asList(firstElement, secondElement).iterator()); final Record rootRecord = mockRecord(recordName, rootStruct); when(rootRecord.getList(listName)).thenReturn(recordList); assertThat(RecordSetter.getSetterCommands(rootRecord)).containsExactly( "set record_name->list_name[1]->i2_field = 123 go", "set record_name->list_name[2]->i2_field = 456 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);  }