All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mockito.internal.exceptions.util.ScenarioPrinter Maven / Gradle / Ivy

There is a newer version: 2.0.2-beta
Show newest version
/*
 * Copyright (c) 2007 Mockito contributors
 * This program is made available under the terms of the MIT License.
 */
package org.mockito.internal.exceptions.util;

import java.util.List;

import org.mockito.internal.exceptions.VerificationAwareInvocation;

public class ScenarioPrinter {

    public String print(List invocations) {
        if (invocations.size() == 1) {
            return "Actually, above is the only interaction with this mock.";
        }
        StringBuilder sb = new StringBuilder(
                "***\n" +
                "For your reference, here is the list of all invocations ([?] - means unverified).\n");
        
        int counter = 0;
        for (VerificationAwareInvocation i : invocations) {
            sb.append(++counter + ". ");
            if (!i.isVerified()) {
                sb.append("[?]");
            }
            sb.append(i.getLocation() + "\n");
        }
        String scenario = sb.toString();
        return scenario;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy