@@ -0,0 +1,3078 @@
+/*%0A * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.%0A *%0A * WSO2 Inc. licenses this file to you under the Apache License,%0A * Version 2.0 (the %22License%22); you may not use this file except%0A * in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing,%0A * software distributed under the License is distributed on an%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0A * KIND, either express or implied.  See the License for the%0A * specific language governing permissions and limitations%0A * under the License.%0A */%0A%0Apackage org.wso2.carbon.uuf.renderablecreator.hbs.helpers.runtime;%0A%0Aimport com.github.jknack.handlebars.io.StringTemplateSource;%0Aimport org.wso2.carbon.uuf.api.config.Configuration;%0Aimport org.wso2.carbon.uuf.core.API;%0Aimport org.wso2.carbon.uuf.core.Lookup;%0Aimport org.wso2.carbon.uuf.core.RequestLookup;%0Aimport org.wso2.carbon.uuf.renderablecreator.hbs.core.HbsRenderable;%0Aimport org.wso2.carbon.uuf.renderablecreator.hbs.impl.HbsPageRenderable;%0Aimport org.wso2.carbon.uuf.spi.HttpRequest;%0A%0Aimport java.util.Collections;%0Aimport java.util.Optional;%0A%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.spy;%0Aimport static org.mockito.Mockito.when;%0A%0A/**%0A * Utility methods for the runtime Handlebars helpers test classes.%0A *%0A * @since 1.0.0%0A */%0Apublic class RuntimeHelpersTestUtil %7B%0A%0A    public static HbsRenderable createRenderable(String sourceStr) %7B%0A        StringTemplateSource stringTemplateSource = new StringTemplateSource(%22%3Ctest-source%3E%22, sourceStr);%0A        return new HbsPageRenderable(stringTemplateSource);%0A    %7D%0A%0A    public static Lookup createLookup() %7B%0A        Lookup lookup = mock(Lookup.class);%0A        Configuration configuration = createConfiguration();%0A        when(lookup.getConfiguration()).thenReturn(configuration);%0A        return lookup;%0A    %7D%0A%0A    public static Configuration createConfiguration() %7B%0A        Configuration configuration = mock(Configuration.class);%0A        when(configuration.other()).thenReturn(Collections.emptyMap());%0A        return configuration;%0A    %7D%0A%0A    public static RequestLookup createRequestLookup() %7B%0A        HttpRequest request = mock(HttpRequest.class);%0A        when(request.getQueryParams()).thenReturn(Collections.emptyMap());%0A        return spy(new RequestLookup(%22/contextPath%22, request, null));%0A    %7D%0A%0A    public static API createAPI() %7B%0A        API api = mock(API.class);%0A        when(api.getSession()).thenReturn(Optional.empty());%0A        return api;%0A    %7D%0A%0A    public static RequestLookup.RenderingFlowTracker createRenderingFlowTracker(boolean isInFragment) %7B%0A        RequestLookup.RenderingFlowTracker tracker = mock(RequestLookup.RenderingFlowTracker.class);%0A        if (isInFragment) %7B%0A            when(tracker.isInFragment()).thenReturn(true);%0A        %7D else %7B%0A            when(tracker.isInPage()).thenReturn(true);%0A            when(tracker.isInLayout()).thenReturn(true);%0A        %7D%0A        return tracker;%0A    %7D%0A%7D%0A

add RuntimeHelpersTestUtil test helper class