Package com.volantis.mcs.runtime.policies

Examples of com.volantis.mcs.runtime.policies.ActivatedVariablePolicyMock


                new SelectedVariantMock("selectedVariantMock", expectations);

        assetResolverMock.expects.selectBestVariant(policyReferenceMock, null)
                .returns(selectedVariantMock).any();

        final ActivatedVariablePolicyMock policyMock =
                new ActivatedVariablePolicyMock("policyMock",
                        expectations);

        selectedVariantMock.expects.getPolicy()
                .returns(policyMock).any();
View Full Code Here


                new SelectedVariantMock("selectedVariantMock", expectations);

        assetResolverMock.expects.selectBestVariant(policyReferenceMock, null)
                .returns(selectedVariantMock).any();

        final ActivatedVariablePolicyMock policyMock =
                new ActivatedVariablePolicyMock("policyMock",
                        expectations);

        selectedVariantMock.expects.getPolicy()
                .returns(null).any();
View Full Code Here

        final ScriptLibraryManager slm = new ScriptLibraryManager(protocolMock);
        final VariantMock variantMock =
            new VariantMock("VariantMock", expectations);
        variantMock.expects.getVariantType().returns(VariantType.SCRIPT).any();

        final ActivatedVariablePolicyMock policyMock1 =
            new ActivatedVariablePolicyMock("ActivatedVariablePolicyMock1",
                expectations);
        policyMock1.expects.getName().returns("name1").any();
        final SelectedVariantMock selectedVariantMock1 =
            new SelectedVariantMock("SelectedVariantMock1", expectations);
        assetResolverMock.expects.selectBestVariant(
            runtimePolicyReferenceMock1, null).returns(selectedVariantMock1).any();
        selectedVariantMock1.expects.getVariant().returns(variantMock).any();
        selectedVariantMock1.expects.getPolicy().returns(policyMock1).any();
        selectedVariantMock1.expects.getOldObject().returns(
            new ScriptAsset("name1", "deviceName1", "javascript1", "mimeType1",
                "charSet1", ScriptAsset.URL, "assetGroupName1", "value1")).any();
        final DefaultComponentScriptAssetReference scriptAssetReference1 =
            new DefaultComponentScriptAssetReference(
                runtimePolicyReferenceMock1, assetResolverMock);
        assertTrue(slm.addScript(scriptAssetReference1));

        final ActivatedVariablePolicyMock policyMock2 =
            new ActivatedVariablePolicyMock("ActivatedVariablePolicyMock2",
                expectations);
        policyMock2.expects.getName().returns("name2").any();
        final SelectedVariantMock selectedVariantMock2 =
            new SelectedVariantMock("SelectedVariantMock2", expectations);
        selectedVariantMock2.expects.getVariant().returns(variantMock).any();
        selectedVariantMock2.expects.getPolicy().returns(policyMock2).any();
        selectedVariantMock2.expects.getOldObject().returns(
            new ScriptAsset("name2", "deviceName2", "javascript2", "mimeType2",
                "charSet2", ScriptAsset.URL, "assetGroupName2", "value2")).any();
        assetResolverMock.expects.selectBestVariant(
            runtimePolicyReferenceMock2, null).returns(selectedVariantMock2).any();
        final DefaultComponentScriptAssetReference scriptAssetReference2 =
            new DefaultComponentScriptAssetReference(
                runtimePolicyReferenceMock2, assetResolverMock);
        assertTrue(slm.addScript(scriptAssetReference2));

        final SelectedVariantMock selectedVariantMock1b =
            new SelectedVariantMock("SelectedVariantMock1b", expectations);
        selectedVariantMock1b.expects.getVariant().returns(variantMock).any();
        selectedVariantMock1b.expects.getPolicy().returns(policyMock1).any();
        selectedVariantMock1b.expects.getOldObject().returns(new ScriptAsset(
            "name1b", "deviceName1b", "javascript1b", "mimeType1b", "charSet1b",
            ScriptAsset.URL, "assetGroupName1b", "value1b")).any();
        final DefaultComponentScriptAssetReference scriptAssetReference1b =
            new DefaultComponentScriptAssetReference(
                runtimePolicyReferenceMock1, assetResolverMock);
        assertFalse(slm.addScript(scriptAssetReference1b));

        final ActivatedVariablePolicyMock policyMock3 =
            new ActivatedVariablePolicyMock("ActivatedVariablePolicyMock3",
                expectations);
        policyMock3.expects.getName().returns("name3").any();
        final SelectedVariantMock selectedVariantMock3 =
            new SelectedVariantMock("SelectedVariantMock3", expectations);
        selectedVariantMock3.expects.getVariant().returns(variantMock).any();
        selectedVariantMock3.expects.getPolicy().returns(policyMock3).any();
        selectedVariantMock3.expects.getOldObject().returns(
            new ScriptAsset("name3", "deviceName3", "javascript3", "mimeType3",
                "charSet3", ScriptAsset.URL, "assetGroupName3", "value3")).any();
        assetResolverMock.expects.selectBestVariant(
            runtimePolicyReferenceMock3, null).returns(selectedVariantMock3).any();
        final DefaultComponentScriptAssetReference scriptAssetReference3 =
            new DefaultComponentScriptAssetReference(
                runtimePolicyReferenceMock3, assetResolverMock);
        assertTrue(slm.addScript(scriptAssetReference3));

        assetResolverMock.expects.computeURLAsString(selectedVariantMock1).
            returns("source1").any();
        assetResolverMock.expects.computeURLAsString(selectedVariantMock2).
            returns("source2").any();
        assetResolverMock.expects.computeURLAsString(selectedVariantMock3).
            returns("source3").any();

        assetResolverMock.expects.rewriteURLWithPageURLRewriter("source1", PageURLType.SCRIPT)
            .returns("source1").any();
        assetResolverMock.expects.rewriteURLWithPageURLRewriter("source2", PageURLType.SCRIPT)
            .returns("source2").any();
        assetResolverMock.expects.rewriteURLWithPageURLRewriter("source3", PageURLType.SCRIPT)
            .returns("source3").any();
       
        slm.writeScriptElements();

        assertEquals(3, scriptAttributesList.size());
        final ScriptAttributes scriptAttributes1 =
            (ScriptAttributes) scriptAttributesList.get(0);
        assertEquals("charSet1", scriptAttributes1.getCharSet());
        assertEquals("javascript1", scriptAttributes1.getLanguage());
        assertEquals("source1", scriptAttributes1.getScriptReference().getURL());
        final ScriptAttributes scriptAttributes2 =
            (ScriptAttributes) scriptAttributesList.get(1);
        assertEquals("charSet2", scriptAttributes2.getCharSet());
        assertEquals("javascript2", scriptAttributes2.getLanguage());
        assertEquals("source2", scriptAttributes2.getScriptReference().getURL());
        final ScriptAttributes scriptAttributes3 =
            (ScriptAttributes) scriptAttributesList.get(2);
        assertEquals("charSet3", scriptAttributes3.getCharSet());
        assertEquals("javascript3", scriptAttributes3.getLanguage());
        assertEquals("source3", scriptAttributes3.getScriptReference().getURL());

        final Element headRoot =
            ((DOMOutputBuffer) pageHead.getHead()).getRoot();
        assertEquals("DELETE_ME", ((Element) headRoot.getHead()).getName());

        final ActivatedVariablePolicyMock policyMock4 =
            new ActivatedVariablePolicyMock("ActivatedVariablePolicyMock4",
                expectations);
        policyMock4.expects.getName().returns("name4").any();
        final SelectedVariantMock selectedVariantMock4 =
            new SelectedVariantMock("SelectedVariantMock4", expectations);
        selectedVariantMock4.expects.getVariant().returns(variantMock).any();
View Full Code Here

    private static final InternalDeviceFactory INTERNAL_DEVICE_FACTORY =
        InternalDeviceFactory.getDefaultInstance();

    public void testAddParentRules() {

        final ActivatedVariablePolicyMock policyMock =
            new ActivatedVariablePolicyMock("policyMock", expectations);

        final VariantMock deviceVariantMock =
            new VariantMock("deviceVariantMock", expectations);
        deviceVariantMock.expects.getVariantType().returns(
            VariantType.THEME).any();
View Full Code Here

TOP

Related Classes of com.volantis.mcs.runtime.policies.ActivatedVariablePolicyMock

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.