@@ -0,0 +1,2804 @@
+/*%0A * Copyright (C) 2016 the original author or authors.%0A *%0A * This file is part of jBB Application Project.%0A *%0A *  Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  You may obtain a copy of the License at%0A *        http://www.apache.org/licenses/LICENSE-2.0%0A */%0A%0Apackage org.jbb.frontend.web.base.logic.view;%0A%0Aimport com.google.common.collect.Maps;%0A%0Aimport org.jbb.frontend.api.service.UcpService;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.InjectMocks;%0Aimport org.mockito.Mock;%0Aimport org.mockito.Spy;%0Aimport org.mockito.runners.MockitoJUnitRunner;%0Aimport org.springframework.web.servlet.ModelAndView;%0A%0Aimport java.util.Map;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;%0Aimport static org.mockito.BDDMockito.given;%0Aimport static org.mockito.Matchers.eq;%0Aimport static org.mockito.Mockito.times;%0Aimport static org.mockito.Mockito.verify;%0A%0A@RunWith(MockitoJUnitRunner.class)%0Apublic class UcpReplacingViewStrategyTest %7B%0A    @Mock%0A    private ModelAndView modelAndViewMock;%0A%0A    @Spy%0A    private Map%3CString, Object%3E modelSpy = Maps.newHashMap();%0A%0A    @Mock%0A    private UcpService ucpServiceMock;%0A%0A    @InjectMocks%0A    private UcpReplacingViewStrategy ucpReplacingViewStrategy;%0A%0A    @Before%0A    public void setUp() throws Exception %7B%0A        given(modelAndViewMock.getModel()).willReturn(modelSpy);%0A    %7D%0A%0A    @Test%0A    public void shouldHandle_whenViewNameStartsWithUcp() throws Exception %7B%0A        // given%0A        given(modelAndViewMock.getViewName()).willReturn(%22ucp/overview/statistics%22);%0A%0A        // when%0A        boolean canHandle = ucpReplacingViewStrategy.canHandle(modelAndViewMock);%0A%0A        // then%0A        assertThat(canHandle).isTrue();%0A    %7D%0A%0A    @Test%0A    public void shouldNotHandle_whenViewNameNotStartWithUcp() throws Exception %7B%0A        // given%0A        given(modelAndViewMock.getViewName()).willReturn(%22members%22);%0A%0A        // when%0A        boolean canHandle = ucpReplacingViewStrategy.canHandle(modelAndViewMock);%0A%0A        // then%0A        assertThat(canHandle).isFalse();%0A    %7D%0A%0A    @Test%0A    public void shouldSetUcpLayoutAsContentViewName() throws Exception %7B%0A        // given%0A        given(modelAndViewMock.getViewName()).willReturn(%22ucp/profile/edit%22);%0A%0A        // when%0A        ucpReplacingViewStrategy.performHandle(modelAndViewMock);%0A%0A        // then%0A        verify(modelSpy, times(1)).put(eq(%22contentViewName%22), eq(%22ucpLayout%22));%0A    %7D%0A%0A    @Test%0A    public void shouldSetDefaultLayoutAsViewName() throws Exception %7B%0A        // given%0A        given(modelAndViewMock.getViewName()).willReturn(%22ucp/profile/edit%22);%0A%0A        // when%0A        ucpReplacingViewStrategy.performHandle(modelAndViewMock);%0A%0A        // then%0A        verify(modelAndViewMock, times(1)).setViewName(%22defaultLayout%22);%0A    %7D%0A%0A%7D

Test for ucp replacing view strategy