@Test public void createNode_RenameViewChange() throws Exception { RenameViewChange refactoring = new RenameViewChange(); refactoring.setSchemaName("SCHEMA_NAME"); refactoring.setOldViewName("OLD_NAME"); refactoring.setNewViewName("NEW_NAME"); Element node = new XMLChangeLogSerializer(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()).createNode(refactoring); assertEquals("renameView", node.getTagName()); assertEquals("SCHEMA_NAME", node.getAttribute("schemaName")); assertEquals("OLD_NAME", node.getAttribute("oldViewName")); assertEquals("NEW_NAME", node.getAttribute("newViewName")); }
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);  }