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

sft.report.decorators.HtmlBreadcrumb Maven / Gradle / Ivy

/*******************************************************************************
 * Copyright (c) 2013, 2014 Sylvain Lézier.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Sylvain Lézier - initial implementation
 *******************************************************************************/
package sft.report.decorators;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import sft.DefaultConfiguration;
import sft.UseCase;
import sft.report.RelativeHtmlPathResolver;
import sft.result.UseCaseResult;

public class HtmlBreadcrumb extends HtmlDecorator {


    public HtmlBreadcrumb(DefaultConfiguration configuration) {
        super(configuration);
    }

    @Override
    public String applyOnUseCase(UseCaseResult useCaseResult, String... parameters) {
        String result = getHtmlReport().applyOnUseCase(useCaseResult);
        final Document parse = Jsoup.parse(result);
        parse.select(".page-header .text-center").append("
    " + printFirstUseCase(useCaseResult.useCase,useCaseResult.useCase) + "
"); return parse.toString(); } private String printFirstUseCase(UseCase initialUseCase,UseCase useCaseToBreadcrumb) { String result = ""; if (useCaseToBreadcrumb.parent != null) { result = printFirstUseCase(initialUseCase,useCaseToBreadcrumb.parent); } if(initialUseCase == useCaseToBreadcrumb){ return result + "
  • " + useCaseToBreadcrumb.getName() + "
  • "; }else{ final RelativeHtmlPathResolver relativeHtmlPathResolver = configuration.getReport().pathResolver; final String origin = relativeHtmlPathResolver.getPathOf(initialUseCase.classUnderTest, ".html"); final String target = relativeHtmlPathResolver.getPathOf(useCaseToBreadcrumb.classUnderTest, ".html"); final String pathToUseCaseToBreadcrumb = relativeHtmlPathResolver.getRelativePathToFile(origin, target); return result + "
  • " + useCaseToBreadcrumb.getName() + "
  • "; } } }




    © 2015 - 2024 Weber Informatics LLC | Privacy Policy