use of software.amazon.awssdk.services.iotsitewise.model.DescribeAssetModelResponse in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class SiteWiseClientTest method testDescribeAssetModel.
/**
******DescribeAssetModel API tests**********
*/
@Test
public void testDescribeAssetModel() {
// when
when(ioTSiteWiseClient.describeAssetModel((DescribeAssetModelRequest) any())).thenReturn(describeAssetModelResponse);
// then
DescribeAssetModelResponse describeAssetModelResponse = siteWiseClient.describeAssetModel(SITE_WISE_ASSET_MODEL_ID);
// verify
assertEquals(describeAssetModelResponse.assetModelName(), SITE_WISE_ASSET_MODEL_NAME);
}
use of software.amazon.awssdk.services.iotsitewise.model.DescribeAssetModelResponse in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class SiteWiseClient method isAssetInheritedFromAssetModel.
/**
* Check whether given siteWiseAssetId belongs to given siteWiseAssetModel. Return true if asset's model contains
* given siteWiseAssetModelPrefix, otherwise return false.
* @param siteWiseAssetId siteWiseAssetId
* @param siteWiseAssetModelPrefix siteWiseAssetModelPrefix
* @return true|false
* @throws EdgeConnectorForKVSException - EdgeConnectorForKVS generic exception
*/
public boolean isAssetInheritedFromAssetModel(@NonNull String siteWiseAssetId, @NonNull String siteWiseAssetModelPrefix) throws EdgeConnectorForKVSException {
final DescribeAssetResponse describeAssetResponse;
final String assetModelId;
try {
describeAssetResponse = describeAsset(siteWiseAssetId);
assetModelId = describeAssetResponse.assetModelId();
if (assetModelId != null) {
DescribeAssetModelResponse describeAssetModelResponse = describeAssetModel(assetModelId);
if (describeAssetModelResponse.assetModelName() != null) {
return describeAssetModelResponse.assetModelName().startsWith(siteWiseAssetModelPrefix);
} else {
log.error(String.format("Could not find the model name for given siteWise assetId and siteWise " + "assetModel Id. Return false. siteWiseAssetId : %s, siteWiseAssetModelId : %s", siteWiseAssetId, assetModelId));
return false;
}
} else {
final String errorMessage = String.format("Could not find the model ID for given siteWiseAssetId. " + "Return false. siteWiseAssetId : %s", siteWiseAssetId);
log.error(errorMessage);
return false;
}
} catch (Exception e) {
final String errorMessage = String.format("Failed to in isAssetBelongsAssetModel API call." + " siteWiseAssetId: %s, siteWiseAssetModelPrefix : %s", siteWiseAssetId, siteWiseAssetModelPrefix);
log.error(errorMessage, e);
throw new EdgeConnectorForKVSException(errorMessage, e);
}
}
Aggregations