Skip to content
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

Add helpers for accessing sample resources #14706

Merged
merged 3 commits into from
Sep 2, 2020

Conversation

abhipsaMisra
Copy link
Member

@abhipsaMisra abhipsaMisra commented Sep 2, 2020

Add helper classes for accessing sample resources.

@abhipsaMisra abhipsaMisra force-pushed the feature/adt/abmisr/samples branch from 1c772f1 to 6121eaf Compare September 2, 2020 01:10
@@ -78,6 +78,11 @@
</dependencies>

<build>
<resources>
<resource>
<directory>src/samples/resources</directory>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maven has inbuilt references to src/main/resources and src/test/resources. We need to add reference to src/samples/resources explicitly.

public class DigitalTwinsLifecycleSample {
private static final ClientLogger logger = new ClientLogger(DigitalTwinsLifecycleSample.class);

private static final String tenantId = System.getenv("TENANT_ID");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: Add a command line options helper similar to .NET

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the "TODO:" as a comment so we can find it and resolve it later?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take care of this


private static final int MaxTimeForTwinOperationsInSeconds = 10;

private static final URL DtdlDirectoryUrl = DigitalTwinsLifecycleSample.class.getClassLoader().getResource("DTDL");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path to "resources" is returned as a URL

aVoid -> { },
throwable -> {
// If digital twin does not exist, ignore.
if (!(throwable instanceof ErrorResponseException) || !((ErrorResponseException) throwable).getValue().getError().getCode().equals("DigitalTwinNotFound")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How to access response status code? ErrorResponse.getValue().getError().getCode() is string.

public class DigitalTwinsLifecycleSample {
private static final ClientLogger logger = new ClientLogger(DigitalTwinsLifecycleSample.class);

private static final String tenantId = System.getenv("TENANT_ID");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will take care of this

throw new RuntimeException(e);
}
TwinsPath = Paths.get(DtDlDirectoryPath.toString(), "DigitalTwins");
ModelsPath = Paths.get(DtDlDirectoryPath.toString(), "Models");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ModelPath and RelationshipsPath is not used here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be, in the rest of the sample (this sample creates models and relationships) :)

@abhipsaMisra abhipsaMisra merged commit 73a8ec3 into master Sep 2, 2020
@abhipsaMisra abhipsaMisra deleted the feature/adt/abmisr/samples branch September 2, 2020 18:06
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.

2 participants