Package it.hotel.aspects

Examples of it.hotel.aspects.MultiLingualInterceptor


  public void testAfterReturningSingleObject() throws Throwable {
   
    ILocaleContainer localeContainer = createMock(ILocaleContainer.class);
    ILabelManager labelManager = createMock(ILabelManager.class);
   
    MultiLingualInterceptor interceptor = new MultiLingualInterceptor();
    interceptor.setLabelManager(labelManager);
    interceptor.setLocaleContainer(localeContainer);
   
    Hotel h = new Hotel();
    h.setBriefdescription("Hotel.Briefdescription");
    h.setDescription("Hotel.Description");
    h.setId(1);
   
    HotelManager hmanager = new HotelManager();
    Class cls = HotelManager.class;
   
    Method m = cls.getMethod("get", new Class[] {int.class});
   
    expect(localeContainer.getLocale()).andReturn("it");
    expectLastCall().anyTimes();
   
    Label label = new Label();
    label.setCode("Hotel.Briefdescription");
    label.setId(1);
    label.setLanguage("it");
    label.setText("this is something");
   
    expect(labelManager.getLabel(1, "Hotel.Briefdescription", "it")).andReturn(label);
    expect(labelManager.getLabel(1, "Hotel.Description", "it")).andReturn(label);
   
   
    replay(localeContainer);
    replay(labelManager);
   
    Integer i = new Integer(1);
    try {
      interceptor.afterReturning(h, m, new Object[] {i}, hmanager)
    }catch (Throwable t){
      assertTrue(false);
    }
   
    assertEquals(h.getBriefdescription(),"this is something");
View Full Code Here


 
  public void testAfterReturningACollection() throws Exception {
    ILocaleContainer localeContainer = createMock(ILocaleContainer.class);
    ILabelManager labelManager = createMock(ILabelManager.class);
   
    MultiLingualInterceptor interceptor = new MultiLingualInterceptor();
    interceptor.setLabelManager(labelManager);
    interceptor.setLocaleContainer(localeContainer);
   
    Hotel h = new Hotel();
    h.setBriefdescription("Hotel.Briefdescription");
    h.setDescription("Hotel.Description");
    h.setId(1);
   
    Hotel h1 = new Hotel();
    h1.setBriefdescription("Hotel.Briefdescription");
    h1.setDescription("Hotel.Description");
    h1.setId(2);
   
    ArrayList<Hotel> hotellist = new ArrayList<Hotel>();
    hotellist.add(h);
    hotellist.add(h1);
   
    Label label = new Label();
    label.setCode("Hotel.Briefdescription");
    label.setId(1);
    label.setLanguage("it");
    label.setText("this is something");
   
    Label label2 = new Label();
    label2.setCode("Hotel.Briefdescription");
    label2.setId(2);
    label2.setLanguage("it");
    label2.setText("this is something else");
   
   
    HotelManager hmanager = new HotelManager();
    Class cls = HotelManager.class;
   
    Method m = cls.getMethod("getAll");
   
    expect(labelManager.getLabel(1, "Hotel.Briefdescription", "it")).andReturn(label);
    expect(labelManager.getLabel(1, "Hotel.Description", "it")).andReturn(label);
    expect(labelManager.getLabel(2, "Hotel.Briefdescription", "it")).andReturn(label2);
    expect(labelManager.getLabel(2, "Hotel.Description", "it")).andReturn(label2);
    expect(localeContainer.getLocale()).andReturn("it");
    expectLastCall().anyTimes();
   
    replay(localeContainer);
    replay(labelManager);
   
    Integer i = new Integer(1);
    try {
      interceptor.afterReturning(hotellist, m, null, hmanager)
    }catch (Throwable t){
      assertTrue(false);
    }
   
    assertEquals(h.getBriefdescription(),"this is something");
View Full Code Here

 
  public void testRecursivelyTestLabelsForObject() throws Exception {
    ILocaleContainer localeContainer = createMock(ILocaleContainer.class);
    ILabelManager labelManager = createMock(ILabelManager.class);
   
    MultiLingualInterceptor interceptor = new MultiLingualInterceptor();
    interceptor.setLabelManager(labelManager);
    interceptor.setLocaleContainer(localeContainer);
   
   
    Hotel h = new Hotel();
    h.setBriefdescription("Hotel.Briefdescription");
    h.setDescription("Hotel.Description");
    h.setId(1);
   
    Room room = new Room();
    room.setId(1);
    room.setStructure(h);
   
    Typology typology = new Typology();
    typology.setId(1);
    typology.setName("something");
   
    room.setTypology(typology);
   
    RoomManager rmanager = new RoomManager();
    Class cls = RoomManager.class;
   
    Method m = cls.getMethod("get", new Class[] {int.class});
   
    expect(localeContainer.getLocale()).andReturn("it");
    expectLastCall().anyTimes();
   
    Label label = new Label();
    label.setCode("Typology.Name");
    label.setId(1);
    label.setLanguage("it");
    label.setText("Doppia");
   
    expect(labelManager.getLabel(1, "Typology.Name", "it")).andReturn(label);
   
    replay(localeContainer);
    replay(labelManager);
   
    Integer i = new Integer(1);
    try {
      interceptor.afterReturning(room, m, new Object[] {i}, rmanager)
    }catch (Throwable t){
      assertTrue(false);
    }
   
    assertEquals(room.getTypology().getName(),"Doppia");
View Full Code Here

 
  public void testRecursivelyTestLabelsForEmptyObject() throws Exception {
    ILocaleContainer localeContainer = createMock(ILocaleContainer.class);
    ILabelManager labelManager = createMock(ILabelManager.class);
   
    MultiLingualInterceptor interceptor = new MultiLingualInterceptor();
    interceptor.setLabelManager(labelManager);
    interceptor.setLocaleContainer(localeContainer);
   
   
    Hotel h = new Hotel();
    h.setBriefdescription("Hotel.Briefdescription");
    h.setDescription("Hotel.Description");
    h.setId(1);
   
    Room room = new Room();
    room.setId(1);
    room.setStructure(h);
   
    //Typology has no values set to simulate hibernate not populating the object
    Typology typology = new Typology();
    typology.setId(1);
   
    room.setTypology(typology);
   
    RoomManager rmanager = new RoomManager();
    Class cls = RoomManager.class;
   
    Method m = cls.getMethod("get", new Class[] {int.class});
   
    expect(localeContainer.getLocale()).andReturn("it");
    expectLastCall().anyTimes();
   
   
    replay(localeContainer);
    replay(labelManager);
   
    Integer i = new Integer(1);
    try {
      interceptor.afterReturning(room, m, new Object[] {i}, rmanager)
    }catch (Throwable t){
      assertTrue(false);
    }
   
    assertNull(room.getTypology().getName());
View Full Code Here

TOP

Related Classes of it.hotel.aspects.MultiLingualInterceptor

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.