removePropertyInDB(repository, (PropertyImpl)node3.getProperty("jcr:primaryType"));
removePropertyInDB(repository, (PropertyImpl)node2.getProperty("jcr:primaryType"));
removePropertyInDB(repository, (PropertyImpl)node1.getProperty("jcr:primaryType"));
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_NOT_CONSISTENT_MESSAGE));
InconsistencyRepair repair = getNodeRemover(repository);
// check correctness repairing child with parent without primaryType property
Connection conn = getConnection(repository);
ResultSet resultSet = getResultSetWithNode(repository, conn, node3);
resultSet.next();
repair.doRepair(resultSet);
resultSet.close();
conn.close();
// check correctness repairing parent with child without primaryType property
repair = getNodeRemover(repository);
conn = getConnection(repository);
resultSet = getResultSetWithNode(repository, conn, node1);
resultSet.next();
repair.doRepair(resultSet);
resultSet.close();
conn.close();
// check correctness repairing node already removed in previous check
repair = getNodeRemover(repository);
Map<String, String> strFields = new HashMap<String, String>();
strFields.put(DBConstants.COLUMN_PARENTID, "already-removed-parentId");
strFields.put(DBConstants.COLUMN_NAME, "[]" + node2.getName());
strFields.put(DBConstants.COLUMN_ID, node2.getIdentifier());
Map<String, Integer> intFields = new HashMap<String, Integer>();
intFields.put(DBConstants.COLUMN_NORDERNUM, 1);
intFields.put(DBConstants.COLUMN_VERSION, 0);
intFields.put(DBConstants.COLUMN_INDEX, 0);
resultSet = new FakeResultSet(strFields, intFields);
repair.doRepair(resultSet);
assertTrue(checkController.checkDataBase().startsWith(RepositoryCheckController.REPORT_CONSISTENT_MESSAGE));
helper.removeRepository(container, repository.getConfiguration().getName());
}