@Test public void createNode_AlterSequenceChange() throws Exception { AlterSequenceChange refactoring = new AlterSequenceChange(); refactoring.setSchemaName("SCHEMA_NAME"); refactoring.setSequenceName("SEQ_NAME"); refactoring.setIncrementBy(new BigInteger("1")); refactoring.setMaxValue(new BigInteger("2")); refactoring.setMinValue(new BigInteger("3")); refactoring.setOrdered(true); Element node = new XMLChangeLogSerializer(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()).createNode(refactoring); assertEquals("alterSequence", node.getNodeName()); assertEquals("SCHEMA_NAME", node.getAttribute("schemaName")); assertEquals("SEQ_NAME", node.getAttribute("sequenceName")); assertEquals("1", node.getAttribute("incrementBy")); assertEquals("2", node.getAttribute("maxValue")); assertEquals("3", node.getAttribute("minValue")); assertEquals("true", node.getAttribute("ordered")); }
public Element createNode(SqlVisitor visitor) { Element node = currentChangeLogFileDOM.createElementNS(XMLChangeLogSAXParser.getDatabaseChangeLogNameSpace(), visitor.getName()); try { List<Field> allFields = new ArrayList<Field>(); Class classToExtractFieldsFrom = visitor.getClass(); while (!classToExtractFieldsFrom.equals(Object.class)) { allFields.addAll(Arrays.asList(classToExtractFieldsFrom.getDeclaredFields())); classToExtractFieldsFrom = classToExtractFieldsFrom.getSuperclass(); } for (Field field : allFields) { field.setAccessible(true); ChangeProperty changePropertyAnnotation = field.getAnnotation(ChangeProperty.class); if (changePropertyAnnotation != null && !changePropertyAnnotation.includeInSerialization()) { continue; } if (field.getName().equals("serialVersionUID")) { continue; } if (field.getName().equals("$VRc")) { continue; } String propertyName = field.getName(); Object value = field.get(visitor); if (value != null) { node.setAttribute(propertyName, value.toString()); } } } catch (Exception e) { throw new UnexpectedLiquibaseException(e); } return node; }
XMLChangeLogSerializer implements ChangeLogSerializer { public Element createNode(SqlVisitor visitor) { Element node = currentChangeLogFileDOM.createElementNS(XMLChangeLogSAXParser.getDatabaseChangeLogNameSpace(), visitor.getName()); try { List<Field> allFields = new ArrayList<Field>(); Class classToExtractFieldsFrom = visitor.getClass(); while (!classToExtractFieldsFrom.equals(Object.class)) { allFields.addAll(Arrays.asList(classToExtractFieldsFrom.getDeclaredFields())); classToExtractFieldsFrom = classToExtractFieldsFrom.getSuperclass(); } for (Field field : allFields) { field.setAccessible(true); ChangeProperty changePropertyAnnotation = field.getAnnotation(ChangeProperty.class); if (changePropertyAnnotation != null && !changePropertyAnnotation.includeInSerialization()) { continue; } if (field.getName().equals("serialVersionUID")) { continue; } if (field.getName().equals("$VRc")) { continue; } String propertyName = field.getName(); Object value = field.get(visitor); if (value != null) { node.setAttribute(propertyName, value.toString()); } } } catch (Exception e) { throw new UnexpectedLiquibaseException(e); } return node; } }
XMLChangeLogSerializer implements ChangeLogSerializer { public Element createNode(SqlVisitor visitor) { Element node = currentChangeLogFileDOM.createElementNS(XMLChangeLogSAXParser.getDatabaseChangeLogNameSpace(), visitor.getName()); try { List<Field> allFields = new ArrayList<Field>(); Class classToExtractFieldsFrom = visitor.getClass(); while (!classToExtractFieldsFrom.equals(Object.class)) { allFields.addAll(Arrays.asList(classToExtractFieldsFrom.getDeclaredFields())); classToExtractFieldsFrom = classToExtractFieldsFrom.getSuperclass(); } for (Field field : allFields) { field.setAccessible(true); ChangeProperty changePropertyAnnotation = field.getAnnotation(ChangeProperty.class); if (changePropertyAnnotation != null && !changePropertyAnnotation.includeInSerialization()) { continue; } if (field.getName().equals("serialVersionUID")) { continue; } if (field.getName().equals("$VRc")) { continue; } String propertyName = field.getName(); Object value = field.get(visitor); if (value != null) { node.setAttribute(propertyName, value.toString()); } } } catch (Exception e) { throw new UnexpectedLiquibaseException(e); } return node; } XMLChangeLogSerializer(); protected  XMLChangeLogSerializer(Document currentChangeLogFileDOM); }
XMLChangeLogSerializer implements ChangeLogSerializer { public Element createNode(SqlVisitor visitor) { Element node = currentChangeLogFileDOM.createElementNS(XMLChangeLogSAXParser.getDatabaseChangeLogNameSpace(), visitor.getName()); try { List<Field> allFields = new ArrayList<Field>(); Class classToExtractFieldsFrom = visitor.getClass(); while (!classToExtractFieldsFrom.equals(Object.class)) { allFields.addAll(Arrays.asList(classToExtractFieldsFrom.getDeclaredFields())); classToExtractFieldsFrom = classToExtractFieldsFrom.getSuperclass(); } for (Field field : allFields) { field.setAccessible(true); ChangeProperty changePropertyAnnotation = field.getAnnotation(ChangeProperty.class); if (changePropertyAnnotation != null && !changePropertyAnnotation.includeInSerialization()) { continue; } if (field.getName().equals("serialVersionUID")) { continue; } if (field.getName().equals("$VRc")) { continue; } String propertyName = field.getName(); Object value = field.get(visitor); if (value != null) { node.setAttribute(propertyName, value.toString()); } } } catch (Exception e) { throw new UnexpectedLiquibaseException(e); } return node; } XMLChangeLogSerializer(); protected  XMLChangeLogSerializer(Document currentChangeLogFileDOM); void setCurrentChangeLogFileDOM(Document currentChangeLogFileDOM); String[] getValidFileExtensions(); String serialize(DatabaseChangeLog databaseChangeLog); String serialize(Change change); String serialize(SqlVisitor visitor); String serialize(ColumnConfig columnConfig); String serialize(ChangeSet changeSet); void write(List<ChangeSet> changeSets, OutputStream out); Element createNode(SqlVisitor visitor); Element createNode(Change change); Element createNode(String nodeName, String nodeContent); Element createNode(ColumnConfig columnConfig); Element createNode(ChangeSet changeSet); Element createNode(CustomChangeWrapper change); }
XMLChangeLogSerializer implements ChangeLogSerializer { public Element createNode(SqlVisitor visitor) { Element node = currentChangeLogFileDOM.createElementNS(XMLChangeLogSAXParser.getDatabaseChangeLogNameSpace(), visitor.getName()); try { List<Field> allFields = new ArrayList<Field>(); Class classToExtractFieldsFrom = visitor.getClass(); while (!classToExtractFieldsFrom.equals(Object.class)) { allFields.addAll(Arrays.asList(classToExtractFieldsFrom.getDeclaredFields())); classToExtractFieldsFrom = classToExtractFieldsFrom.getSuperclass(); } for (Field field : allFields) { field.setAccessible(true); ChangeProperty changePropertyAnnotation = field.getAnnotation(ChangeProperty.class); if (changePropertyAnnotation != null && !changePropertyAnnotation.includeInSerialization()) { continue; } if (field.getName().equals("serialVersionUID")) { continue; } if (field.getName().equals("$VRc")) { continue; } String propertyName = field.getName(); Object value = field.get(visitor); if (value != null) { node.setAttribute(propertyName, value.toString()); } } } catch (Exception e) { throw new UnexpectedLiquibaseException(e); } return node; } XMLChangeLogSerializer(); protected  XMLChangeLogSerializer(Document currentChangeLogFileDOM); void setCurrentChangeLogFileDOM(Document currentChangeLogFileDOM); String[] getValidFileExtensions(); String serialize(DatabaseChangeLog databaseChangeLog); String serialize(Change change); String serialize(SqlVisitor visitor); String serialize(ColumnConfig columnConfig); String serialize(ChangeSet changeSet); void write(List<ChangeSet> changeSets, OutputStream out); Element createNode(SqlVisitor visitor); Element createNode(Change change); Element createNode(String nodeName, String nodeContent); Element createNode(ColumnConfig columnConfig); Element createNode(ChangeSet changeSet); Element createNode(CustomChangeWrapper change);  }