Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * *********************************************************************************************************************
   *
   * NorthernWind - lightweight CMS
   * http://northernwind.tidalwave.it - hg clone https://bitbucket.org/tidalwave/northernwind-src
   * %%
   * Copyright (C) 2011 - 2014 Tidalwave s.a.s. (http://tidalwave.it)
   * %%
  * *********************************************************************************************************************
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations under the License.
  *
  * *********************************************************************************************************************
  *
  * $Id: ViewBuilderTest.java,v f214f4c8488f 2014/01/03 18:03:50 fabrizio $
  *
  * *********************************************************************************************************************
  * #L%
  */
 package it.tidalwave.northernwind.frontend.impl.ui;
 
 import  it.tidalwave.util.Id;
 import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.CoreMatchers.*;
 import static org.mockito.Mockito.*;

Author(s):
Fabrizio Giudici
Version:
$Id: ViewBuilderTest.java,v f214f4c8488f 2014/01/03 18:03:50 fabrizio $ /
 
 public class ViewBuilderTest
   {
     public static class MockView
       {
         public final Id id;
         public final SiteNode siteNode;
         public final Site site;
         public final MockService1 service1;
       }
 
     public static class MockController
       {
         public final Id id;
         public final SiteNode siteNode;
         public final MockView view;
         public final Site site;
         public final MockService2 service2;
       }
 
     private ViewBuilder fixture;
 
 
     private SiteNode siteNode;
 
     private Id id;
 
     private Site site;
 
     private SiteProvider siteProvider;
 
     private MockService1 service1;
 
     private MockService2 service2;

    
/
 
     @BeforeMethod
     public void setupFixture()
       throws Exception
       {
          = new ClassPathXmlApplicationContext("ViewBuilderTestBeans.xml");
          = .getBean(SiteProvider.class);
          = .getBean(MockService1.class);
          = .getBean(MockService2.class);
 
          = mock(SiteNode.class);
         when(.getSite()).thenReturn();
         = new Id("theId");
         = new ViewBuilder(MockView.classMockController.class);
      }

    
/
    @Test
      throws Exception
      {
        final ViewAndController viewAndController = .createViewAndController();
        final Object oController = viewAndController.getController();
        final Object oView = viewAndController.getView();
        assertThat(oControlleris(not(nullValue())));
        assertThat(oViewis(not(nullValue())));
        assertThat(oControlleris(instanceOf(MockController.class)));
        assertThat(oViewis(instanceOf(MockView.class)));
        final MockController controller = (MockController)oController;
        final MockView view = (MockView)oView;
        assertThat(controller.viewis(sameInstance(view)));
        assertThat(controller.siteNodeis(sameInstance()));
        assertThat(controller.idis());
        assertThat(controller.siteis(sameInstance()));
        assertThat(controller.service2is(sameInstance()));
        assertThat(view.siteNodeis(sameInstance()));
        assertThat(view.idis());
        assertThat(view.siteis(sameInstance()));
        assertThat(view.service1is(sameInstance()));
      }
  }
New to GrepCode? Check out our FAQ X