-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
1c772f1
to
6121eaf
Compare
@@ -78,6 +78,11 @@ | |||
</dependencies> | |||
|
|||
<build> | |||
<resources> | |||
<resource> | |||
<directory>src/samples/resources</directory> |
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.
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"); |
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.
TODO: Add a command line options helper similar to .NET
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.
Can you add the "TODO:" as a comment so we can find it and resolve it later?
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 will take care of this
|
||
private static final int MaxTimeForTwinOperationsInSeconds = 10; | ||
|
||
private static final URL DtdlDirectoryUrl = DigitalTwinsLifecycleSample.class.getClassLoader().getResource("DTDL"); |
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 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")) { |
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.
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"); |
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 will take care of this
throw new RuntimeException(e); | ||
} | ||
TwinsPath = Paths.get(DtDlDirectoryPath.toString(), "DigitalTwins"); | ||
ModelsPath = Paths.get(DtDlDirectoryPath.toString(), "Models"); |
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.
ModelPath and RelationshipsPath is not used here.
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 will be, in the rest of the sample (this sample creates models and relationships) :)
Add helper classes for accessing sample resources.