当前位置: 首页>>代码示例>>Java>>正文


Java Spec类代码示例

本文整理汇总了Java中com.galenframework.specs.Spec的典型用法代码示例。如果您正苦于以下问题:Java Spec类的具体用法?Java Spec怎么用?Java Spec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Spec类属于com.galenframework.specs包,在下文中一共展示了Spec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validate

import com.galenframework.specs.Spec; //导入依赖的package包/类
public void validate(Spec spec, RelativeElement relativeElement) {
    try {
        PageValidationWrapper pageValidation = getPageValidation(spec, relativeElement);
        ValidationResult result = pageValidation.check(ObjectName, spec);
        if (result.getError() != null) {
            onError(spec, result);
        } else {
            onSuccess(spec, result);

        }
    } catch (Exception ex) {
        Logger.getLogger(General.class
                .getName()).log(Level.SEVERE, null, ex);
        onError(ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:General.java

示例2: checkObject

import com.galenframework.specs.Spec; //导入依赖的package包/类
private List<ValidationResult> checkObject(String objectName, List<Spec> specs) {
    List<ValidationResult> validationResults = new LinkedList<>();

    for (Spec spec : specs) {
        tellBeforeSpec(pageValidation, objectName, spec);

        ValidationResult result = pageValidation.check(objectName, spec);
        if (result.getError()!= null) {
            validationResults.add(result);
            tellOnSpecError(pageValidation, objectName, spec, result);
        }
        else {
            tellOnSpecSuccess(pageValidation, objectName, spec, result);
        }
    }

    return validationResults;
}
 
开发者ID:galenframework,项目名称:galen,代码行数:19,代码来源:SectionValidation.java

示例3: process

import com.galenframework.specs.Spec; //导入依赖的package包/类
@Override
public Spec process(StringCharReader reader, String contextPath) {

    String objectName = reader.readWord();
    if (objectName.isEmpty()) {
        throw new SyntaxException("Missing object name");
    }

    Range range;
    if (reader.hasMore()) {
        range = Expectations.range().read(reader);
    }
    else {
        range = Range.greaterThanOrEquals(new RangeValue(0));
    }


    return createSpec(objectName, range);
}
 
开发者ID:galenframework,项目名称:galen,代码行数:20,代码来源:SpecWithObjectAndRangeProcessor.java

示例4: process

import com.galenframework.specs.Spec; //导入依赖的package包/类
@Override
public Spec process(StringCharReader reader, String contextPath) {
    boolean partly = false;

    int initialCursorPosition = reader.currentCursorPosition();

    if (reader.readWord().equals("partly")) {
        partly = true;
    } else {
        reader.moveCursorTo(initialCursorPosition);
    }

    List<String> objectNames = Expectations.readAllWords(reader.takeTheRest());

    if (objectNames.size() == 0) {
        throw new SyntaxException(MISSING_OBJECT_NAME);
    }

    return new SpecContains(objectNames, partly);
}
 
开发者ID:galenframework,项目名称:galen,代码行数:21,代码来源:SpecContainsProcessor.java

示例5: process

import com.galenframework.specs.Spec; //导入依赖的package包/类
@Override
public Spec process(StringCharReader reader, String contextPath) {
    SpecCount.FetchType fetchType = SpecCount.FetchType.parse(word().read(reader));

    String pattern = null;
    if (reader.firstNonWhiteSpaceSymbol() == '\"') {
        pattern = doubleQuotedText().read(reader);
    } else {
        pattern = word().read(reader);
    }

    if (pattern == null || pattern.isEmpty()) {
        throw new SyntaxException("Pattern should not be empty");
    }

    expectNextWord("is", reader);

    ExpectRange rangeExpectation = new ExpectRange();
    rangeExpectation.setNoEndingWord();
    Range range = rangeExpectation.read(reader);

    return new SpecCount(fetchType, pattern, range);
}
 
开发者ID:galenframework,项目名称:galen,代码行数:24,代码来源:SpecCountProcessor.java

示例6: process

import com.galenframework.specs.Spec; //导入依赖的package包/类
@Override
public Spec process(StringCharReader reader, String contextPath) {
    SpecComponent spec = new SpecComponent();

    int initialPosition = reader.currentCursorPosition();
    if (reader.readWord().equals("frame")) {
        spec.setFrame(true);
    } else {
        reader.moveCursorTo(initialPosition);
    }

    String filePath = reader.readSafeUntilSymbol(',').trim();

    List<Pair<String, String>> unprocessedArguments = Expectations.commaSeparatedRepeatedKeyValues().read(reader);
    spec.setArguments(processArguments(unprocessedArguments));

    if (contextPath != null && !contextPath.equals(".")) {
        filePath = contextPath + File.separator + filePath;
    }

    spec.setSpecPath(filePath);
    return spec;
}
 
开发者ID:galenframework,项目名称:galen,代码行数:24,代码来源:SpecComponentProcessor.java

示例7: process

import com.galenframework.specs.Spec; //导入依赖的package包/类
@Override
public Spec process(StringCharReader reader, String contextPath) {

    String cssPropertyName = reader.readWord();
    String validationTypeString = reader.readWord();
    if (cssPropertyName.isEmpty()) {
        throw new SyntaxException("Missing css property name");
    }
    if (validationTypeString.isEmpty()) {
        throw new SyntaxException("Missing validation type (is, contains, starts, ends, matches)");
    }

    SpecText.Type validationType = SpecText.Type.fromString(validationTypeString);

    String expectedText = Expectations.doubleQuotedText().read(reader);


    if (reader.hasMoreNormalSymbols()) {
        throw new SyntaxException("Too many arguments for spec: " + reader.getTheRest().trim());
    }

    return new SpecCss(cssPropertyName, validationType, expectedText);
}
 
开发者ID:galenframework,项目名称:galen,代码行数:24,代码来源:SpecCssProcessor.java

示例8: onBeforeSpec

import com.galenframework.specs.Spec; //导入依赖的package包/类
@Override
public void onBeforeSpec(PageValidation pageValidation, String objectName, Spec originalSpec) {
    LayoutSpec spec = new LayoutSpec();
    spec.setPlace(originalSpec.getPlace());
    spec.setName(originalSpec.getOriginalText());

    if (originalSpec.getAlias() != null) {
        LayoutSpecGroup group = new LayoutSpecGroup();
        group.setName(originalSpec.getAlias());
        group.addSpec(spec);
        currentReport().getCurrentObject().addSpecGroup(group);
    } else {
        currentReport().getCurrentSpecCollector().add(spec);
    }

    currentReport().setCurrentSpec(spec);
}
 
开发者ID:galenframework,项目名称:galen,代码行数:18,代码来源:LayoutReportListener.java

示例9: onSpecError

import com.galenframework.specs.Spec; //导入依赖的package包/类
@Override
public void onSpecError(PageValidation pageValidation, String objectName, Spec originalSpec, ValidationResult result) {
    LayoutSpec spec = currentReport().getCurrentSpec();
    addResultToSpec(spec, result);

    if (originalSpec.isOnlyWarn()) {
        spec.setStatus(TestReportNode.Status.WARN);
    }

    try {
        if (result.getError().getImageComparison() != null) {
            spec.setImageComparison(convertImageComparison(objectName, result.getError().getImageComparison()));
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

}
 
开发者ID:galenframework,项目名称:galen,代码行数:19,代码来源:LayoutReportListener.java

示例10: shouldCheckLayout_inJsTests_andPassCustomJsVariables

import com.galenframework.specs.Spec; //导入依赖的package包/类
@Test
public void shouldCheckLayout_inJsTests_andPassCustomJsVariables() throws Exception {
    String testUrl = getClass().getResource("/suites/custom-js-variables-for-checklayout/simple.test.js").getFile();
    GalenMain galen = new GalenMain();
    final List<String> errorMessages = new LinkedList<>();

    CompleteListener listener = new DummyCompleteListener() {
        @Override
        public void onSpecError(PageValidation pageValidation, String objectName, Spec spec, ValidationResult result) {
            errorMessages.addAll(result.getError().getMessages());
        }
    };
    galen.setListener(listener);
    galen.execute("test", testUrl);

    assertThat(errorMessages, hasItems("\"caption\" text is \"Hi my name is John\" but should be \"Hi my name is Jack\""));
}
 
开发者ID:galenframework,项目名称:galen,代码行数:18,代码来源:GalenMainTest.java

示例11: check

import com.galenframework.specs.Spec; //导入依赖的package包/类
@Override
public ValidationResult check(String objectName, Spec spec) {
    ((PageSpecWrapper) this.getPageSpec()).setObjectMap(elementMap);
    SpecValidation<?> specValidation = ValidationFactoryWrapper.getValidation(spec, this);

    ValidationResult result = check(specValidation, objectName, spec);

    if (spec.isOnlyWarn()) {
        result.getError().setOnlyWarn(true);
    }
    return result;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:PageValidationWrapper.java

示例12: getValidation

import com.galenframework.specs.Spec; //导入依赖的package包/类
public static SpecValidation<? extends Spec> getValidation(Spec spec, PageValidation pageValidation) {
    try {
        return ValidationFactory.getValidation(spec, pageValidation);
    } catch (Exception ex) {
        if (spec.getClass().equals(SpecUrl.class)) {
            return new SpecValidationUrl();
        } else if (spec.getClass().equals(SpecTitle.class)) {
            return new SpecValidationTitle();
        } else if (spec.getClass().equals(SpecAttribute.class)) {
            return new SpecValidationAttribute();
        }
        throw ex;
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:15,代码来源:PageValidationWrapper.java

示例13: processAlignment

import com.galenframework.specs.Spec; //导入依赖的package包/类
private Spec processAlignment(String objectName, String value, String type) {
    StringCharReader reader = new StringCharReader(value);
    String[] words = ExpectWord.readAllWords(reader);
    Alignment alignment = Alignment.ALL;
    int errorRate = 0;
    if (words.length == 1) {
        errorRate = Parser.parseInt(words[0]);
        if (errorRate == 0) {
            alignment = Alignment.parse(words[0]);
        }
    } else if (words.length == 2) {
        alignment = Alignment.parse(words[0]);
        errorRate = Parser.parseInt(words[1]);
    }

    switch (type) {
        case "horizontally":
            if (alignment.isOneOf(CENTERED, TOP, BOTTOM, ALL)) {
                return new SpecHorizontally(alignment, objectName).withErrorRate(errorRate);
            } else {
                throw new SyntaxException("Horizontal alignment doesn't allow this side: " + alignment.toString());
            }
        case "vertically":
            if (alignment.isOneOf(CENTERED, LEFT, RIGHT, ALL)) {
                return new SpecVertically(alignment, objectName).withErrorRate(errorRate);
            } else {
                throw new SyntaxException("Verticall alignment doesn't allow this side: " + alignment.toString());
            }
        default:
            throw new SyntaxException("Unknown alignment: " + type);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:33,代码来源:SpecReader.java

示例14: onError

import com.galenframework.specs.Spec; //导入依赖的package包/类
public void onError(Spec spec, ValidationResult result) {
    if (result.getError().getImageComparison() != null) {
        onResult(result, Status.FAIL, saveImageComparison(result.getError().getImageComparison()));
    } else {
        onResult(result, Status.FAIL);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:8,代码来源:Report.java

示例15: getPageValidation

import com.galenframework.specs.Spec; //导入依赖的package包/类
public PageValidationWrapper getPageValidation(Spec spec, RelativeElement relativeElement) {
    Map<String, WebElement> elementMap = getRelativeElement(relativeElement);
    if (Element != null) {
        elementMap.put(ObjectName, Element);
    }
    if (spec instanceof SpecImage) {
        Optional.ofNullable(((SpecImage) spec).getIgnoredObjectExpressions())
                .ifPresent((ioe) -> ioe.stream().flatMap((expr) -> Stream.of(expr.split(",")))
                .forEach((String object) -> {
                    elementMap.put(object, AObject.findElement(object, Reference));
                }));
    }
    return new PageValidationWrapper(new PageWrapper(Driver, elementMap), elementMap);
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:15,代码来源:General.java


注:本文中的com.galenframework.specs.Spec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。