@Test(enabled = false) public void checkCurrentStateAgainstBenchmark() throws Throwable { Map<String, HashMap<String, String>> previousState = UpgradeHelper.parseBenchmarkState(); Map<String, HashMap<String, String>> currentState = UpgradeHelper.populateCurrentState(); for (Map.Entry<String, HashMap<String, String>> prevState : previousState.entrySet()) { if (prevState.getKey().equals(safelyDeletedFieldsName)) { // Ignore this since it is not an actual entity class continue; } // Verify that the entity is here if (!currentState.containsKey(prevState.getKey())) { System.out.println( "This entity is not found in the current system " + prevState.getKey()); } assertThat(currentState.containsKey(prevState.getKey()), is(true)); HashMap<String, String> currentFields = currentState.get(prevState.getKey()); HashMap<String, String> prevFields = prevState.getValue(); for (Map.Entry<String, String> prevField : prevFields.entrySet()) { // Verify that field is here not deleted, not renamed if (!currentFields.containsKey(prevField.getKey())) { // Check if it is safe to delete if (isSafeToDelete( previousState.get(safelyDeletedFieldsName), prevState.getKey(), prevField.getKey())) { continue; } else { System.out.println( "This field " + prevField.getKey() + " is not found in the current system on this entity " + prevState.getKey()); assertThat(currentFields.containsKey(prevField.getKey()), is(true)); } } String prevType = prevField.getValue(); String currentType = currentFields.get(prevField.getKey()); if (!prevType.equals(currentType) && !prevType.replace("esxcloud", "photon.controller").equals(currentType)) { // Now check if it is assignable Class<?> prevFieldType = null; try { prevFieldType = Class.forName(prevType); } catch (ClassNotFoundException ex) { // May be its namespace is renamed prevFieldType = Class.forName(prevType.replace("esxcloud", "photon.controller")); } Class<?> currentFieldType = Class.forName(currentType); System.out.println( "This field " + prevField.getKey() + " has different type " + prevType + " in the current system " + currentType + "on this entity" + prevState.getKey()); assertThat(currentFieldType.isAssignableFrom(prevFieldType), is(true)); } } } }
// Enable when you want to generate a benchmark file @Test(enabled = false) public void generateBenchmarkFile() throws Throwable { UpgradeHelper.generateBenchmarkFile(); }