-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add generic executions * feat: add generic cartography * test: add generic cartography * doc: add generic adapter documentation * chore: update api to 8.1.0 * chore: update web-ui to 8.1.0 * fix: remove timed annotation * fix: sonar lombok analysis Co-authored-by: Thomas GRUSON <thomas.gruson@protonmail.com>
- Loading branch information
1 parent
a7152b7
commit 342d987
Showing
33 changed files
with
2,079 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
159 changes: 159 additions & 0 deletions
159
.../src/main/java/com/decathlon/ara/scenario/generic/bean/GenericExecutedScenarioReport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
/****************************************************************************** | ||
* Copyright (C) 2020 by the ARA Contributors * | ||
* * | ||
* 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 com.decathlon.ara.scenario.generic.bean; | ||
|
||
import com.decathlon.ara.scenario.generic.bean.description.GenericExecutedScenarioDescription; | ||
import com.decathlon.ara.scenario.generic.bean.display.GenericExecutedScenarioResultsDisplay; | ||
import com.decathlon.ara.scenario.generic.bean.error.GenericExecutedScenarioError; | ||
import com.decathlon.ara.scenario.generic.bean.feature.GenericExecutedScenarioFeature; | ||
import com.decathlon.ara.scenario.generic.bean.log.GenericExecutedScenarioLogs; | ||
import com.fasterxml.jackson.annotation.JsonFormat; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Date; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
@Data | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class GenericExecutedScenarioReport { | ||
|
||
private String code; | ||
|
||
private String name; | ||
|
||
private GenericExecutedScenarioFeature feature; | ||
|
||
private GenericExecutedScenarioDescription description; | ||
|
||
@JsonProperty("start") | ||
@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss") | ||
private Date startDate; | ||
|
||
private boolean ignored; | ||
|
||
private List<GenericExecutedScenarioError> errors; | ||
|
||
private List<Long> cartography; | ||
|
||
private GenericExecutedScenarioResultsDisplay display; | ||
|
||
private GenericExecutedScenarioLogs logs; | ||
|
||
private List<String> tags; | ||
|
||
private String severity; | ||
|
||
@JsonProperty("server") | ||
private String serverName; | ||
|
||
private String comment; | ||
|
||
/** | ||
* Get functionalities name | ||
* @return the functionalities name | ||
*/ | ||
public String getFunctionalitiesName() { | ||
String cartographyAsString = ""; | ||
if (!CollectionUtils.isEmpty(cartography)) { | ||
String cartographyIdsAsString = cartography | ||
.stream() | ||
.map(String::valueOf) | ||
.collect(Collectors.joining(", ")); | ||
cartographyAsString = String.format("Functionality %s", cartographyIdsAsString); | ||
} | ||
String separator = ""; | ||
if (StringUtils.isNotBlank(cartographyAsString) && StringUtils.isNotBlank(name)) { | ||
separator = ": "; | ||
} | ||
return String.format("%s%s%s", cartographyAsString, separator, StringUtils.isBlank(name) ? "" : name); | ||
} | ||
|
||
/** | ||
* Convert tags into a string. If no tags, then return an empty string | ||
* @param tags the tags to convert | ||
* @return the string representation of the tags | ||
*/ | ||
public static String convertTagsToString(List<String> tags) { | ||
if (CollectionUtils.isEmpty(tags)) { | ||
return ""; | ||
} | ||
return tags | ||
.stream() | ||
.map(tag -> String.format("@%s", tag)) | ||
.collect(Collectors.joining(" ")); | ||
} | ||
|
||
/** | ||
* Get tags representation as string | ||
* @return tags representation as string | ||
*/ | ||
public String getTagsAsString() { | ||
return convertTagsToString(tags); | ||
} | ||
|
||
/** | ||
* Get country codes as string from tags and feature tags | ||
* @return country codes as string | ||
*/ | ||
public String getCountryCodesAsString() { | ||
List<String> countryCodes = getCountryCodes(); | ||
if (CollectionUtils.isEmpty(countryCodes)) { | ||
return "all"; | ||
} | ||
return countryCodes.stream().collect(Collectors.joining(",")); | ||
} | ||
|
||
/** | ||
* Get country codes from tags and feature tags | ||
* @return country codes | ||
*/ | ||
public List<String> getCountryCodes() { | ||
List<String> countryCodesFromTags = getCountryCodesFromTags(tags); | ||
List<String> countryCodesFromFeatureTags = feature != null ? | ||
getCountryCodesFromTags(feature.getTags()) : | ||
new ArrayList<>(); | ||
return Stream.of(countryCodesFromTags, countryCodesFromFeatureTags) | ||
.flatMap(Collection::stream) | ||
.distinct() | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
/** | ||
* Get country codes from tags | ||
* @param tags the tags to get the country codes from | ||
* @return country codes | ||
*/ | ||
private static List<String> getCountryCodesFromTags(List<String> tags) { | ||
if (CollectionUtils.isEmpty(tags)) { | ||
return new ArrayList<>(); | ||
} | ||
return tags.stream() | ||
.filter(tag -> tag.startsWith("country-")) | ||
.map(tag -> tag.substring("country-".length())) | ||
.distinct() | ||
.collect(Collectors.toList()); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
...m/decathlon/ara/scenario/generic/bean/description/GenericExecutedScenarioDescription.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/****************************************************************************** | ||
* Copyright (C) 2020 by the ARA Contributors * | ||
* * | ||
* 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 com.decathlon.ara.scenario.generic.bean.description; | ||
|
||
import com.decathlon.ara.scenario.generic.bean.description.step.GenericExecutedScenarioStep; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.With; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Data | ||
@With | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class GenericExecutedScenarioDescription { | ||
|
||
private List<GenericExecutedScenarioStep> steps; | ||
|
||
@JsonProperty("start_line") | ||
private Integer startLineNumber; | ||
|
||
/** | ||
* Get a string displaying all the steps content | ||
* @return the steps content | ||
*/ | ||
public String getStepsContent() { | ||
if (CollectionUtils.isEmpty(steps)) { | ||
return ""; | ||
} | ||
return steps.stream() | ||
.map(GenericExecutedScenarioStep::getStepLine) | ||
.collect(Collectors.joining("\n")); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
...com/decathlon/ara/scenario/generic/bean/description/step/GenericExecutedScenarioStep.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/****************************************************************************** | ||
* Copyright (C) 2020 by the ARA Contributors * | ||
* * | ||
* 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 com.decathlon.ara.scenario.generic.bean.description.step; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.With; | ||
|
||
import java.util.Optional; | ||
|
||
@Data | ||
@With | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class GenericExecutedScenarioStep { | ||
|
||
private Long line; | ||
|
||
private String status; | ||
|
||
private Long value; | ||
|
||
private String content; | ||
|
||
public Optional<Long> getOptionalValue() { | ||
return Optional.ofNullable(value); | ||
} | ||
|
||
/** | ||
* Get step line as string | ||
* @return get step line | ||
*/ | ||
public String getStepLine() { | ||
String valueAsString = getOptionalValue() | ||
.map(String::valueOf) | ||
.map(v -> ":" + v) | ||
.orElse(""); | ||
return String.format("%d:%s%s:%s", line, status, valueAsString, content); | ||
} | ||
} |
Oops, something went wrong.