Search in sources :

Example 1 with AssetOptionsProvider

use of com.emc.sa.asset.AssetOptionsProvider in project coprhd-controller by CoprHD.

the class ServiceDescriptorAssetTest method verifyAssetFields.

private void verifyAssetFields(ServiceDescriptor descriptor) {
    Set<String> allAssetTypes = descriptor.getAllAssetTypes();
    for (ServiceField field : descriptor.getAllFieldList()) {
        if (!field.isAsset()) {
            continue;
        }
        String assetType = field.getAssetType();
        AssetOptionsProvider provider = assetManager.getProviderForAssetType(assetType);
        if (provider == null) {
            Assert.fail(String.format("%s [%s]: No provider found for type: %s", descriptor.getTitle(), field.getName(), assetType));
        }
        try {
            List<String> assetDependencies = provider.getAssetDependencies(assetType, allAssetTypes);
            for (String assetDependency : assetDependencies) {
                AssetOptionsProvider dependencyProvider = assetManager.getProviderForAssetType(assetDependency);
                if (dependencyProvider == null) {
                    Assert.fail(String.format("%s [%s]: No provider found for dependency '%s' of type: %s", descriptor.getTitle(), field.getName(), assetDependency, assetType));
                }
            }
        } catch (IllegalStateException e) {
            Assert.fail(String.format("%s [%s]: Could not query dependencies of type: %s, provided: %s", descriptor.getTitle(), field.getName(), assetType, allAssetTypes));
        }
    }
}
Also used : ServiceField(com.emc.sa.descriptor.ServiceField) AssetOptionsProvider(com.emc.sa.asset.AssetOptionsProvider)

Aggregations

AssetOptionsProvider (com.emc.sa.asset.AssetOptionsProvider)1 ServiceField (com.emc.sa.descriptor.ServiceField)1