Skip to content

Commit

Permalink
fix bpe in case of missed executor type (fixes #2283, via #2284)
Browse files Browse the repository at this point in the history
  • Loading branch information
baev authored Jan 10, 2024
1 parent e9eafa6 commit 0ad3762
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,17 @@ private static Optional<String> getHostSafe(final String url) {
return Optional.empty();
}

private static String getExecutorType(final List<LaunchResults> launchesResults) {
/* package-private */
static String getExecutorType(final List<LaunchResults> launchesResults) {
return launchesResults.stream()
.map(results -> results.<ExecutorInfo>getExtra(EXECUTORS_BLOCK_NAME))
.filter(Optional::isPresent)
.findFirst()
.filter(Optional::isPresent)
.map(Optional::get)
.map(ExecutorInfo::getType)
.map(String::trim)
.map(String::toLowerCase)
.findFirst()
.orElse(LOCAL);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Copyright 2016-2023 Qameta Software OÜ
*
* 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 io.qameta.allure.ga;

import io.qameta.allure.DefaultLaunchResults;
import io.qameta.allure.entity.ExecutorInfo;
import io.qameta.allure.executor.ExecutorPlugin;
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Map;
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;

/**
* @author charlie (Dmitry Baev).
*/
class GaPluginTest {

@Test
void shouldGetDefaultExecutor() {
final String executorType = GaPlugin.getExecutorType(
List.of(
new DefaultLaunchResults(Set.of(), Map.of(), Map.of())
)
);

assertThat(executorType)
.isEqualTo("local");
}

@Test
void shouldProcessNullExecutor() {
final String executorType = GaPlugin.getExecutorType(
List.of(
new DefaultLaunchResults(Set.of(), Map.of(), Map.of(
ExecutorPlugin.EXECUTORS_BLOCK_NAME,
new ExecutorInfo()
))
)
);

assertThat(executorType)
.isEqualTo("local");
}

@Test
void shouldProcessExecutor() {
final String executorType = GaPlugin.getExecutorType(
List.of(
new DefaultLaunchResults(Set.of(), Map.of(), Map.of(
ExecutorPlugin.EXECUTORS_BLOCK_NAME,
new ExecutorInfo()
.setType("some executor type")
))
)
);

assertThat(executorType)
.isEqualTo("some executor type");
}
}
3 changes: 2 additions & 1 deletion gradle/quality-configs/pmd/pmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description>
General Java quality rules.
</description>

<!-- Best practices (https://pmd.github.io/pmd-6.0.1/pmd_rules_java_bestpractices.html) -->
<rule ref="category/java/bestpractices.xml">
<exclude name="AbstractClassWithoutAbstractMethod"/>
Expand All @@ -32,6 +32,7 @@
<exclude name="CallSuperInConstructor"/>
<exclude name="CommentDefaultAccessModifier"/>
<exclude name="ConfusingTernary"/>
<exclude name="DefaultPackage"/>
<exclude name="GenericsNaming"/>
<exclude name="LinguisticNaming"/>
<exclude name="LocalHomeNamingConvention"/> <!-- earlier j2ee group-->
Expand Down

0 comments on commit 0ad3762

Please sign in to comment.