package no.steria.skuldsku.testrunner.dbrunner.dbverifier.verifiers;

import java.util.List;

import no.steria.skuldsku.common.result.AssertionResult;
import no.steria.skuldsku.common.result.Results;
import no.steria.skuldsku.testrunner.dbrunner.dbchange.DatabaseChange;
import no.steria.skuldsku.testrunner.dbrunner.dbchange.FieldDifference;
import no.steria.skuldsku.testrunner.dbrunner.dbverifier.DatabaseChangeVerifier;
import no.steria.skuldsku.testrunner.dbrunner.dbverifier.DatabaseChangeVerifierOptions;
import no.steria.skuldsku.testrunner.dbrunner.dbverifier.result.DatabaseChangeMatchesResult;
import no.steria.skuldsku.testrunner.dbrunner.dbverifier.result.DatabaseChangeNotEqualsResult;

public class StrictOrderDatabaseChangeVerifier implements DatabaseChangeVerifier {

    @Override
    public Results assertEquals(List<DatabaseChange> expected, List<DatabaseChange> actual, DatabaseChangeVerifierOptions databaseChangeVerifierOptions) {
        final Results databaseChangeVerifierResult = new Results();

        if (expected.size() != actual.size()) {
            databaseChangeVerifierResult.addResult(new AssertionResult("Database actual result size differs from expected", "The actual data (" + actual.size() + ") should be of the same number of entries as the expected data (" + expected.size() + ")."));
        } else {
            for (int i=0; i<expected.size(); i++) {
                final DatabaseChange expectedDatabaseChange = expected.get(i);
                final DatabaseChange actualDatabaseChange = actual.get(i);

                final List<FieldDifference> fieldDifferences = expectedDatabaseChange.determineDifferences(actualDatabaseChange, databaseChangeVerifierOptions.getSkipFields());
                if (!fieldDifferences.isEmpty()) {
                    databaseChangeVerifierResult.addResult(new DatabaseChangeNotEqualsResult(expectedDatabaseChange, actualDatabaseChange, fieldDifferences));
                    break;
                } else if (databaseChangeVerifierOptions.isIncludeSuccessfulMatchesInResult()) {
                    databaseChangeVerifierResult.addResult(new DatabaseChangeMatchesResult(expectedDatabaseChange, actualDatabaseChange));
                }
            }
        }
        
        return databaseChangeVerifierResult;
    }
}

@@ -1028,364 +1028,63 @@
     
-if (expected.size() != actual.size()) %7B%0A            databaseChangeVerifierResult.addResult(new AssertionResult(%22Database actual result size differs from expected%22, %22The actual data (%22 + actual.size() + %22) should be of the same number of entries as the expected data (%22 + expected.size() + %22).%22));%0A        %7D else %7B%0A            for (int i=0; i%3Cexpected.size(
+for (int i=0; i%3CMath.min(actual.size(), expected.size()
 ); i
@@ -1085,28 +1085,24 @@
 ()); i++) %7B%0A
-    
             
@@ -1168,36 +1168,32 @@
 i);%0A            
- 
-   
 final DatabaseCh
@@ -1232,28 +1232,24 @@
 al.get(i);%0A%0A
-    
             
@@ -1405,28 +1405,24 @@
 pFields());%0A
-    
             
@@ -1464,36 +1464,32 @@
                 
-    
 databaseChangeVe
@@ -1627,20 +1627,16 @@
         
-    
 break;%0A 
@@ -1646,20 +1646,16 @@
         
-  
-  
 %7D else i
@@ -1723,28 +1723,24 @@
 Result()) %7B%0A
-    
             
@@ -1878,27 +1878,325 @@
     
-    %7D%0A            %7D
+%7D%0A        %7D%0A%0A        if (expected.size() != actual.size()) %7B%0A            databaseChangeVerifierResult.addResult(new AssertionResult(%22Database actual result size differs from expected%22, %22The actual data (%22 + actual.size() + %22) should be of the same number of entries as the expected data (%22 + expected.size() + %22).%22));
 %0A   

Allow comparision even when result sets have different size.