Package com.microsoft.windowsazure.services.media.models

Examples of com.microsoft.windowsazure.services.media.models.AssetInfo


    private Set<String> createTestAssets(int numAssets, String namePart)
            throws Exception {
        Set<String> expectedAssets = new HashSet<String>();

        for (int i = 0; i < numAssets; ++i) {
            AssetInfo asset = entityService.create(Asset.create().setName(
                    testAssetPrefix + namePart + Integer.toString(i)));
            expectedAssets.add(asset.getId());
        }
        return expectedAssets;
    }
View Full Code Here


    private static void removeAllTestLocators() {
        try {
            ListResult<LocatorInfo> listLocatorsResult = service.list(Locator
                    .list());
            for (LocatorInfo locatorInfo : listLocatorsResult) {
                AssetInfo ai = service.get(Asset.get(locatorInfo.getAssetId()));
                if (ai.getName().startsWith(testAssetPrefix)) {
                    service.delete(Locator.delete(locatorInfo.getId()));
                }
            }
        } catch (Exception e) {
            // e.printStackTrace();
View Full Code Here

    }

    protected static AssetInfo setupAssetWithFile() throws ServiceException {
        String name = UUID.randomUUID().toString();
        String testBlobName = "test" + name + ".bin";
        AssetInfo assetInfo = service.create(Asset.create().setName(
                testAssetPrefix + name));

        AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(
                testPolicyPrefix + name, 10,
                EnumSet.of(AccessPolicyPermission.WRITE)));
        LocatorInfo locator = createLocator(accessPolicyInfo, assetInfo, 5);
        WritableBlobContainerContract blobWriter = service
                .createBlobWriter(locator);
        InputStream blobContent = new ByteArrayInputStream(new byte[] { 4, 8,
                15, 16, 23, 42 });
        blobWriter.createBlockBlob(testBlobName, blobContent);

        service.action(AssetFile.createFileInfos(assetInfo.getId()));

        return assetInfo;
    }
View Full Code Here

        String altId = "altId";
        AssetOption encryptionOption = AssetOption.StorageEncrypted;
        AssetState assetState = AssetState.Published;

        // Act
        AssetInfo actualAsset = service.create(Asset.create()
                .setAlternateId(altId).setOptions(encryptionOption)
                .setState(assetState).setName(testName));

        // Assert
        verifyAssetProperties("actualAsset", testName, altId, encryptionOption,
View Full Code Here

        String testName = testAssetPrefix + "createAssetMeanString"
                + meanString;

        // Act
        AssetInfo actualAsset = service
                .create(Asset.create().setName(testName));

        // Assert
        assertEquals("actualAsset Name", testName, actualAsset.getName());
    }
View Full Code Here

    @Test
    public void createAssetNullNameSuccess() throws Exception {
        // Arrange

        // Act
        AssetInfo actualAsset = null;
        try {
            actualAsset = service.create(Asset.create());
            // Assert
            verifyAssetProperties("actualAsset", "", "", AssetOption.None,
                    AssetState.Initialized, actualAsset);
        } finally {
            // Clean up the anonymous asset now while we have the id, because we
            // do not want to delete all anonymous assets in the bulk-cleanup
            // code.
            try {
                if (actualAsset != null) {
                    service.delete(Asset.delete(actualAsset.getId()));
                }
            } catch (ServiceException ex) {
                // ex.printStackTrace();
            }
        }
View Full Code Here

        String testName = testAssetPrefix + "GetAssetSuccess";
        String altId = "altId";
        AssetOption encryptionOption = AssetOption.StorageEncrypted;
        AssetState assetState = AssetState.Published;

        AssetInfo assetInfo = service.create(Asset.create().setName(testName)
                .setAlternateId(altId).setOptions(encryptionOption)
                .setState(assetState));

        // Act
        AssetInfo actualAsset = service.get(Asset.get(assetInfo.getId()));

        // Assert
        verifyInfosEqual("actualAsset", assetInfo, actualAsset);
    }
View Full Code Here

        // Arrange
        String originalTestName = testAssetPrefix
                + "updateAssetSuccessOriginal";
        AssetOption originalEncryptionOption = AssetOption.StorageEncrypted;
        AssetState originalAssetState = AssetState.Initialized;
        AssetInfo originalAsset = service.create(Asset.create()
                .setName(originalTestName).setAlternateId("altId")
                .setOptions(originalEncryptionOption));

        String updatedTestName = testAssetPrefix + "updateAssetSuccessUpdated";
        String altId = "otherAltId";

        // Act
        service.update(Asset.update(originalAsset.getId())
                .setName(updatedTestName).setAlternateId(altId));
        AssetInfo updatedAsset = service.get(Asset.get(originalAsset.getId()));

        // Assert
        verifyAssetProperties("updatedAsset", updatedTestName, altId,
                originalEncryptionOption, originalAssetState, updatedAsset);
    }
View Full Code Here

    public void updateAssetNoChangesSuccess() throws Exception {
        // Arrange
        String originalTestName = testAssetPrefix
                + "updateAssetNoChangesSuccess";
        String altId = "altId";
        AssetInfo originalAsset = service.create(Asset.create()
                .setName(originalTestName).setAlternateId(altId));

        // Act
        service.update(Asset.update(originalAsset.getId()));
        AssetInfo updatedAsset = service.get(Asset.get(originalAsset.getId()));

        // Assert
        verifyInfosEqual("updatedAsset", originalAsset, updatedAsset);
    }
View Full Code Here

    @Test
    public void deleteAssetSuccess() throws Exception {
        // Arrange
        String assetName = testAssetPrefix + "deleteAssetSuccess";
        AssetInfo assetInfo = service.create(Asset.create().setName(assetName));
        List<AssetInfo> listAssetsResult = service.list(Asset.list());
        int assetCountBaseline = listAssetsResult.size();

        // Act
        service.delete(Asset.delete(assetInfo.getId()));

        // Assert
        listAssetsResult = service.list(Asset.list());
        assertEquals("listAssetsResult.size", assetCountBaseline - 1,
                listAssetsResult.size());

        expectedException.expect(ServiceException.class);
        expectedException.expect(new ServiceExceptionMatcher(404));
        service.get(Asset.get(assetInfo.getId()));
    }
View Full Code Here

TOP

Related Classes of com.microsoft.windowsazure.services.media.models.AssetInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.