Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sanjeevchopra
Copy link
Contributor

No description provided.

Copy link
Contributor Author

@sanjeevchopra sanjeevchopra left a 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 {
Copy link
Contributor Author

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

Copy link
Collaborator

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 {
Copy link
Contributor Author

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

Copy link
Collaborator

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) {
Copy link
Contributor Author

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()) {
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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 ?

Copy link
Collaborator

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.

Copy link
Contributor Author

@sanjeevchopra sanjeevchopra left a 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"
Copy link
Contributor Author

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() {
Copy link
Contributor Author

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.

Copy link
Collaborator

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,
Copy link
Contributor Author

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

Copy link
Collaborator

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 {
Copy link
Contributor Author

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

@sanjeevchopra sanjeevchopra changed the title creating a PR for review only for review only: config API for connectors Mar 13, 2017

private Set<AttributeAdapterConnection> adapters;

public boolean getIsActive() {
Copy link
Contributor Author

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

Copy link
Collaborator

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.

Copy link
Collaborator

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.

@irinaepshteyn irinaepshteyn force-pushed the US92090 branch 3 times, most recently from 55f8438 to 1522538 Compare March 14, 2017 18:07
@FrankGasparovic FrankGasparovic changed the title for review only: config API for connectors US92090: Config API for connectors Mar 15, 2017
@FrankGasparovic FrankGasparovic changed the title US92090: Config API for connectors US92090: REST APIs for resource connector configuration Mar 15, 2017
@FrankGasparovic FrankGasparovic merged commit d97afdd into develop Mar 15, 2017
@anubhavi25 anubhavi25 deleted the US92090 branch March 16, 2017 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants