-
Notifications
You must be signed in to change notification settings - Fork 55
Eiffel2.0 events links validation based on the Bordeaux edition of protocol #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| /** | ||
| * This class is used to read required and optional links from linksValidation.properties file | ||
| * | ||
| * @author xumakap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove author
| public static List<String> getRequiredLinks(String eventType) { | ||
|
|
||
| if (requiredLinksMap.size() == 0 || optionalLinksMap.size() == 0) { | ||
| while (keys.hasMoreElements()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why iterating map, Use directly get from Map
|
|
||
| if(requiredLinks == null && optionalLinks == null) { | ||
| throw new EiffelValidationException(eiffelType.getEventName()+"event links not configured in property file "+CONFIG_FILE); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if may be some of event does not have optional parameters then?
| throw new EiffelValidationException(message, e); | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write method doc comments
http://www.oracle.com/technetwork/articles/java/index-137868.html
| } | ||
| } | ||
|
|
||
| public void linksValidation(EiffelEventType eiffelType, JsonObject jsonObject) throws EiffelValidationException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are validating only Links Object, So do not pass entire event object.
…nal links based on event
|
|
||
| String getEventName() { | ||
| public String getEventName() { | ||
| return id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable name from id to eventName
|
|
||
| import com.ericsson.eiffel.remrem.semantics.schemas.EiffelConstants; | ||
|
|
||
| public enum LinkTypes { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LinkTypes to LinkType
| private final String OPTIONAL_LINKS = "optionalLinks"; | ||
| private final String DOT = "."; | ||
|
|
||
| public LinksConfiguration() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc for the constructor
| } | ||
| return idMap.get(id); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc for the method
| package com.ericsson.eiffel.remrem.semantics; | ||
|
|
||
| import com.ericsson.eiffel.remrem.semantics.schemas.EiffelConstants; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Javadoc for the Enum
| * This method is used to get all link types from LinkTypes Enum | ||
| * @return link types list | ||
| */ | ||
| public List<String> getLinkTypes() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAllLinkTypes
|
|
||
| public class EiffelOutputValidatorFactory { | ||
|
|
||
| private static LinksConfiguration linksConfiguration = new LinksConfiguration(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final keyword
| private List<String> linkTypes; | ||
|
|
||
| public EiffelValidator(String schemaResourceName) { | ||
| public EiffelValidator(String schemaResourceName, String eventType, List<String> requiredLinks, List<String> optionalLinks, List<String> linkTypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requiredLinkTypes, optionalLinkTypes, allLinkTypes
| } | ||
| /** | ||
| * This method is used to validate links in an event | ||
| * @param eiffelType is an event type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove javadoc
| public OutputValidator(String schemaResourceName) { | ||
| super(schemaResourceName); | ||
| public OutputValidator(String schemaResourceName,String eventType, List<String> requiredLinks, List<String> optionalLinks, List<String> linkTypes) { | ||
| super(schemaResourceName, eventType, requiredLinks, optionalLinks, linkTypes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
allLinkTypes
| for (String requiredLink : requiredLinks) { | ||
| Integer count = linksCountMapForEvent.get(requiredLink); | ||
| if (count == null) { | ||
| throw new EiffelValidationException("Mandatory links missing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Link type to EiffelValidationException
…the links in all events
| } catch (MissingResourceException e) { | ||
| return linkTypeList; | ||
| } | ||
| }*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove not needed code
| return getLinkTypesFromConfiguration(key); | ||
| } | ||
|
|
||
| /*private List<String> getLinkTypesFromConfiguration(String key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove commented code
| return getLinkTypesFromConfiguration(key); | ||
| } | ||
|
|
||
| private List<String> getLinkTypesFromConfiguration(String key) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add java doc
|
+1 |
| } | ||
| Set<String> linksSet = new HashSet<>(linksCountMapForEvent.keySet()); | ||
|
|
||
| for (String requiredLinkType : requiredLinkTypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use java8 Lambda Expression
| String CONTEXT_LINK = "CONTEXT"; | ||
| try { | ||
| JsonArray links = jsonObjectInput.get("links").getAsJsonArray(); | ||
| for (JsonElement link : links) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use java 8 Lambda Expression, we can reduce this logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can implement then in upcoming stories related to this.
| throw new EiffelValidationException( | ||
| "Link types " + CAUSE_LINK + " and " + CONTEXT_LINK + " should not be in one event"); | ||
| } | ||
| for (String optionalLinkType : optionalLinkTypes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use java 8 Lambda Expression
SantoshNC68
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please implement the lambda expressions in coming tasks.
No description provided.