org.gradle.tooling.internal.provider.TestExecutionRequestAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-api Show documentation
Show all versions of gradle-api Show documentation
Gradle 6.9.1 API redistribution.
/*
* Copyright 2015 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.tooling.internal.provider;
import com.google.common.collect.ImmutableSet;
import org.gradle.StartParameter;
import org.gradle.api.Transformer;
import org.gradle.tooling.internal.protocol.events.InternalTestDescriptor;
import org.gradle.tooling.internal.protocol.test.InternalJvmTestRequest;
import org.gradle.tooling.internal.provider.test.ProviderInternalJvmTestRequest;
import org.gradle.tooling.internal.provider.test.ProviderInternalTestExecutionRequest;
import org.gradle.util.CollectionUtils;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
public class TestExecutionRequestAction extends SubscribableBuildAction {
private final StartParameter startParameter;
private final Set testDescriptors;
private final Set classNames;
private final Set internalJvmTestRequests;
private TestExecutionRequestAction(BuildClientSubscriptions clientSubscriptions, StartParameter startParameter, ImmutableSet testDescriptors, Set providerClassNames, Set internalJvmTestRequests) {
super(clientSubscriptions);
this.startParameter = startParameter;
this.testDescriptors = testDescriptors;
this.classNames = providerClassNames;
this.internalJvmTestRequests = internalJvmTestRequests;
}
// Unpacks the request to serialize across to the daemon and craetes instance of
// TestExecutionRequestAction
public static TestExecutionRequestAction create(BuildClientSubscriptions clientSubscriptions, StartParameter startParameter, ProviderInternalTestExecutionRequest testExecutionRequest) {
final Collection testClassNames = testExecutionRequest.getTestClassNames();
final Collection internalJvmTestRequests = testExecutionRequest.getInternalJvmTestRequests(Collections.emptyList());
Set providerInternalJvmTestRequests = ImmutableSet.copyOf(toProviderInternalJvmTestRequest(internalJvmTestRequests, testClassNames));
return new TestExecutionRequestAction(clientSubscriptions, startParameter,
ImmutableSet.copyOf(testExecutionRequest.getTestExecutionDescriptors()),
ImmutableSet.copyOf(testClassNames),
providerInternalJvmTestRequests);
}
private static List toProviderInternalJvmTestRequest(Collection internalJvmTestRequests, Collection testClassNames) {
// handle consumer < 2.7
if(internalJvmTestRequests.isEmpty()){
return CollectionUtils.collect(testClassNames, new Transformer() {
@Override
public InternalJvmTestRequest transform(String testClass) {
return new ProviderInternalJvmTestRequest(testClass, null);
}
});
} else {
return CollectionUtils.collect(internalJvmTestRequests, new Transformer() {
@Override
public InternalJvmTestRequest transform(InternalJvmTestRequest internalTestMethod) {
return new ProviderInternalJvmTestRequest(internalTestMethod.getClassName(), internalTestMethod.getMethodName());
}
});
}
}
@Override
public StartParameter getStartParameter() {
return startParameter;
}
public Collection getTestClassNames() {
return classNames;
}
public Collection getInternalJvmTestRequests() {
return internalJvmTestRequests;
}
public Collection getTestExecutionDescriptors() {
return testDescriptors;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy