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");