Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.2.6
- Added links validation to events based on the Bordeaux edition of protocol

## 0.2.5
- added copyright headers to the source code

Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ allprojects {

jar {
baseName = 'eiffel-remrem-semantics'
version = '0.2.5'
version = '0.2.6'
manifest {
attributes('remremVersionKey': 'semanticsVersion')
attributes('semanticsVersion': version)
Expand All @@ -64,7 +64,7 @@ jar {

shadowJar {
baseName = 'eiffel-remrem-semantics'
version = '0.2.5'
version = '0.2.6'
classifier = ''
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,32 @@ public enum EiffelEventType {
ISSUE_VERIFIED("eiffelissueverified"),
ARTIFACT_REUSED("eiffelartifactreused");

private String id;
private String eventType;

EiffelEventType(String id) {
this.id = id;
EiffelEventType(String eventType) {
this.eventType = eventType;
}

static HashMap<String, EiffelEventType> idMap = new HashMap<String, EiffelEventType>();
static HashMap<String, EiffelEventType> eventTypeMap = new HashMap<String, EiffelEventType>();

public static EiffelEventType fromString(String id) {
if (idMap.size() == 0) {
/**
* This method used to get EiffelEventType Enum constant based on event type
* @param eventType of an eiffel event
* @return Enum constant of EiffelEventType
*/
public static EiffelEventType fromString(String eventType) {
if (eventTypeMap.size() == 0) {
for (EiffelEventType type : values())
idMap.put(type.id, type);
eventTypeMap.put(type.eventType, type);
}
return idMap.get(id);
return eventTypeMap.get(eventType);
}

String getEventName() {
return id;

/**
* This method used to get event type of an eiffel event based on Enum constant
* @return event type of an eiffel event
*/
public String getEventName() {
return eventType;
}
}
61 changes: 61 additions & 0 deletions src/main/java/com/ericsson/eiffel/remrem/semantics/LinkType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
Copyright 2017 Ericsson AB.
For a full list of individual contributors, please see the commit history.
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.ericsson.eiffel.remrem.semantics;

import com.ericsson.eiffel.remrem.semantics.schemas.EiffelConstants;

/**
* This class contains list of link types and multiple tracability for those link types.
*
*/
public enum LinkType {

CAUSE(EiffelConstants.MULTIPLE_ALLOWED),
CONTEXT(EiffelConstants.MULTIPLE_NOT_ALLOWED),
FLOW_CONTEXT(EiffelConstants.MULTIPLE_NOT_ALLOWED),
ACTIVITY_EXECUTION(EiffelConstants.MULTIPLE_NOT_ALLOWED),
PREVIOUS_ACTIVITY_EXECUTION(EiffelConstants.MULTIPLE_NOT_ALLOWED),
PREVIOUS_VERSION(EiffelConstants.MULTIPLE_ALLOWED),
COMPOSITION(EiffelConstants.MULTIPLE_NOT_ALLOWED),
ENVIRONMENT(EiffelConstants.MULTIPLE_NOT_ALLOWED),
ARTIFACT(EiffelConstants.MULTIPLE_NOT_ALLOWED),
SUBJECT(EiffelConstants.MULTIPLE_ALLOWED),
ELEMENT(EiffelConstants.MULTIPLE_ALLOWED),
BASE(EiffelConstants.MULTIPLE_NOT_ALLOWED),
CHANGE(EiffelConstants.MULTIPLE_NOT_ALLOWED),
TEST_SUITE_EXECUTION(EiffelConstants.MULTIPLE_NOT_ALLOWED),
TEST_CASE_EXECUTION(EiffelConstants.MULTIPLE_NOT_ALLOWED),
IUT(EiffelConstants.MULTIPLE_NOT_ALLOWED),
TERC(EiffelConstants.MULTIPLE_NOT_ALLOWED),
MODIFIED_ANNOUNCEMENT(EiffelConstants.MULTIPLE_NOT_ALLOWED),
SUB_CONFIDENCE_LEVEL(EiffelConstants.MULTIPLE_ALLOWED),
REUSED_ARTIFACT(EiffelConstants.MULTIPLE_NOT_ALLOWED),
VERIFICATION_BASIS(EiffelConstants.MULTIPLE_ALLOWED);

private final boolean multipleAllowed;

LinkType(boolean multipleAllowed) {
this.multipleAllowed = multipleAllowed;
}

/**
* This method checks multiple traces allowed for a link type
* @return true if multiple traces allowed for the link type
* false if multiple traces not allowed for the link type
*/
public boolean isMultipleAllowed() {
return multipleAllowed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ private void outputValidate(EiffelEventType eiffelType, String jsonStringInput)
EiffelValidator validator = EiffelOutputValidatorFactory.getEiffelValidator(eiffelType);
JsonObject jsonObject = new JsonParser().parse(jsonStringInput).getAsJsonObject();
validator.validate(jsonObject);
//custom validations on an event which is not covered in schema.
validator.customValidation(jsonObject);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
Copyright 2017 Ericsson AB.
For a full list of individual contributors, please see the commit history.
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.ericsson.eiffel.remrem.semantics.config;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.ericsson.eiffel.remrem.semantics.LinkType;

/**
* This class is used to read required and optional link types from linksValidation.properties file
*
*/

public class LinksConfiguration {

private ResourceBundle links;
private List<String> allLinkTypes;
private final String REQUIRED_LINKS = "requiredLinks";
private final String OPTIONAL_LINKS = "optionalLinks";
private final String DOT = ".";

/**
* Initializes links of type ResourceBundle from linksValidation property file and
* allLinkTypes of type list from LinkType Enum class
*/
public LinksConfiguration() {
links = ResourceBundle.getBundle("linksValidation", Locale.getDefault());
allLinkTypes = Stream.of(LinkType.values()).map(LinkType::name).collect(Collectors.toList());
}

/**
* This method is used to get required link types based on event type
* @param eventType of an Eiffel event
* For Eg: eiffelartifactpublished, eiffelactivityfinished
* @return list of link types required for an event else return an empty list
*/
public List<String> getRequiredLinkTypes(String eventType) {
String key = eventType + DOT + REQUIRED_LINKS;
return getLinkTypesFromConfiguration(key);
}

/**
* This method is used to get optional link types based on event type
* @param eventType of an Eiffel event
* For Eg: eiffelartifactpublished, eiffelactivityfinished
* @return list of optional link types for an event else return an empty list
*/
public List<String> getOptionalLinkTypes(String eventType) {
String key = eventType + DOT + OPTIONAL_LINKS;
return getLinkTypesFromConfiguration(key);
}

/**
* This method is used to get link types based on key
* @param key is <eventType>.requiredLinks or <eventType>.optionalLinks
* For Eg: eiffelactivitycanceled.requiredLinks, eiffelactivitycanceled.optionalLinks
* @return list of link types for an event else return an empty list
*/
private List<String> getLinkTypesFromConfiguration(String key) {
List<String> linkTypeList = new ArrayList<String>();
try {
if (!links.getString(key).isEmpty()) {
linkTypeList = Arrays.asList(links.getString(key).split(","));
}
return linkTypeList;
} catch (MissingResourceException e) {
return linkTypeList;
}
}

/**
* This method is used to get all link types from LinkTypes Enum
* @return list of all link types
*/
public List<String> getAllLinkTypes() {
return allLinkTypes;
}
}
Loading