-
Notifications
You must be signed in to change notification settings - Fork 14
US92090: REST APIs for resource connector configuration #98
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
sanjeevchopra
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.
@irinaepshteyn submitting this for initial comments. I am still reviewing other classes.
| @@ -0,0 +1,18 @@ | |||
| package com.ge.predix.acs.attribute.connector.management; | |||
|
|
|||
| public class AttributeConnectorException extends RuntimeException { | |||
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 using this as a checked exception, not runtime. should extend Exception
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.
It's not a true checked exception since we don't have throws in service methods. Also, converting it to checked exception will not work with a stream used to validate adapter configuration:
connector.getAdapters().parallelStream().forEach(adapter -> {
validateAdapterEntityOrFail(adapter);
});
I would rather keep this exception as runtime.
|
|
||
| import com.ge.predix.acs.rest.AttributeConnector; | ||
|
|
||
| public interface AttributeConnectorService { |
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.
minor: not sure if it's worth having a interface for this. Given its not a user visible, class and we only have one implementation for it. We could add a interface when we need a 2nd implementation
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 would leave the interface for consistency with other ACS services
| } | ||
|
|
||
| private void validateAdapterEntityOrFail(final AttributeAdapterConnection adapter) { | ||
| if (adapter == null) { |
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.
this cannot be null
| if (adapter == null) { | ||
| throw new AttributeConnectorException("Attribute connector configuration requires at least one adapter"); | ||
| } | ||
| if (adapter.getAdapterEndpoint() == null || adapter.getAdapterEndpoint().isEmpty()) { |
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.
maybe this is what you are referring to earlier - a lot of this validation can be enforced via jackson using annotations on the AttributeAdapterConnection bean. I believe, by default, a field is required, unless you mark it as optional.
| if (connector.getAdapters() == null || connector.getAdapters().isEmpty()) { | ||
| throw new AttributeConnectorException("Attribute connector configuration requires at least one adapter"); | ||
| } | ||
| if (connector.getMaxCachedIntervalMinutes() < CACHED_INTERVAL_THRESHOLD_MINUTES) { |
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.
lets use jackson for all this validation. Also, if the value of maxCachedIntervalMinutes is not set - it should default to 480 minutes (8hrs). I propose a minimum of 60 mins ?
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.
To unblock other pull requests that depend on this story I would address input validation as a separate story.
sanjeevchopra
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.
Few more comments - i am done with my review.
| </http> | ||
|
|
||
| <!-- Authorization Configuration For V1 subject APIS --> | ||
| <http pattern="/v1/connector/**" request-matcher="ant" create-session="stateless" |
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.
/v1/connector/* ?
| } | ||
|
|
||
| @Test | ||
| public void testCreateResourceConnector() { |
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.
this is and other tests should check affected values in the connector/adapter which was created/updated or removed.
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.
Done
| } | ||
|
|
||
| try { | ||
| this.zone1ConnectorReadClient.exchange(this.acsUrl + V1 + RESOURCE_CONNECTOR_URL, HttpMethod.GET, |
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 add asserts for expected values on connector/adapter properties
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.
Done
| } | ||
|
|
||
| @Test | ||
| public void testCreateResourceConnectorWithCacheaIntervalBelowThreshold() throws Exception { |
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.
the validation tests here should suffice, if we use jackson for validation. Please remove any similar validation tests from the unit test - AttributeConnectorServiceTest
|
|
||
| private Set<AttributeAdapterConnection> adapters; | ||
|
|
||
| public boolean getIsActive() { |
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 rename to isActive. Also, this needs to be saved to the database
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.
Renaming getIsActive to isActive breaks json serialization. isActive will be serialized to active unless we use isIsActive instead.
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.
To unblock other pull requests that depend on this story I would handle persisting isActive as a separate story.
55f8438 to
1522538
Compare
Signed-off-by: Frank <[email protected]>
No description provided.