Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.initialization.exception
import org.gradle.api.GradleScriptException
import org.gradle.api.ProjectConfigurationException
import org.gradle.api.tasks.TaskExecutionException
import org.gradle.groovy.scripts.ScriptSource
import org.gradle.internal.Describables
import org.gradle.internal.exceptions.Contextual
import org.gradle.internal.exceptions.LocationAwareException
import org.gradle.internal.exceptions.MultiCauseException
import org.gradle.internal.exceptions.ResolutionProvider
import org.gradle.problems.Location
import org.gradle.problems.ProblemDiagnostics
import org.gradle.problems.buildtree.ProblemDiagnosticsFactory
import spock.lang.Specification
class DefaultExceptionAnalyserTest extends Specification {
private final ProblemDiagnosticsFactory diagnosticsFactory = Stub(ProblemDiagnosticsFactory)
def 'wraps original exception when it is not a contextual exception'() {
given:
def failure = new RuntimeException()
def analyser = analyser()
def result = []
when:
analyser.collectFailures(failure, result)
then:
result.size() == 1
def transformedFailure = result[0]
transformedFailure instanceof LocationAwareException
transformedFailure.cause.is(failure)
transformedFailure.reportableCauses.isEmpty()
}
def 'wraps contextual exception with location aware exception'() {
given:
def failure = new ContextualException()
def analyser = analyser()
def result = []
when:
analyser.collectFailures(failure, result)
then:
result.size() == 1
def transformedFailure = result[0]
transformedFailure instanceof LocationAwareException
transformedFailure.cause.is(failure)
transformedFailure.reportableCauses.isEmpty()
}
def 'wraps highest contextual exception with location aware exception'() {
given:
def cause = new ContextualException()
def failure = new ContextualException(cause)
def analyser = analyser()
def result = []
when:
analyser.collectFailures(failure, result)
then:
result.size() == 1
def transformedFailure = result[0]
transformedFailure instanceof LocationAwareException
transformedFailure.cause.is(failure)
transformedFailure.reportableCauses == [cause]
}
def 'adds location info from stack trace'() {
def failure = new ContextualException()
def analyser = analyser()
def result = []
given:
_ * diagnosticsFactory.forException(failure) >> location("