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

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

The newest version!
/*******************************************************************************
 * 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.ScenarioResult;
import sft.result.SubUseCaseResult;
import sft.result.UseCaseResult;

public class HtmlTableOfContent extends HtmlDecorator {


    public HtmlTableOfContent(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").after("
"+printUseCase(useCaseResult.useCase, useCaseResult)+"
"); return parse.toString(); } private String printUseCase(UseCase initialUseCase, UseCaseResult useCaseResult) { String result = "
    "; for (SubUseCaseResult subUseCaseResult : useCaseResult.subUseCaseResults) { final RelativeHtmlPathResolver relativeHtmlPathResolver = configuration.getReport().pathResolver; final String origin = relativeHtmlPathResolver.getPathOf(initialUseCase.classUnderTest, ".html"); final String target = relativeHtmlPathResolver.getPathOf(subUseCaseResult.useCaseResult.useCase.classUnderTest, ".html"); final String pathToUseCaseToBreadcrumb = relativeHtmlPathResolver.getRelativePathToFile(origin, target); result += "
  1. " + ""+subUseCaseResult.useCaseResult.useCase.getName()+""+ printScenario(subUseCaseResult.useCaseResult) + printUseCase(initialUseCase, subUseCaseResult.useCaseResult) + "
  2. "; } return result+"
"; } private String printScenario(UseCaseResult useCaseResult) { String result = "
    "; for (ScenarioResult scenarioResult : useCaseResult.scenarioResults) { result += "
  • " + ""+scenarioResult.scenario.getName()+""+ "
  • "; } return result+ "
"; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy