class XcodeBuilder extends Builder implements Script {

    public Element getElementFromLine(String line) {
        if (hitBuildFailedMessage) {
            return messageAtLevel(line, "error");
        }
        
        Element e = messageAtLevelIfContains(line, "warn", " warning: ");
        if (e != null) {
            return e;
        }
        
        e = messageAtLevelIfContains(line, "error", " error: ");
        if (e != null) {
            return e;
        }
        
        e = messageAtLevelIfContains(line, "error", "** BUILD FAILED **");
        if (e != null) {
            hitBuildFailedMessage = true;
            return e;
        }

        return null;
    }

}

class XcodeBuilderTest {

    private XcodeBuilder builder;
    private Directory directoryDoesntFailValidation;
    private Map<String, String> buildProperties;
    private static final String COMPILE_LINE;
    private static final String WARNING_LINE;
    private static final String ERROR_LINE;
    private static final String BUILD_FAILED_LINE;
    private static final String COMMANDS_FAILED_LINE;

    @Test
    public void errorLineShouldReturnErrorElement() {

        Element e = builder.getElementFromLine(ERROR_LINE);
        assertMessageAtLevel(ERROR_LINE, e, "error");
    }

}