SHARE
TWEET

Untitled

a guest Jul 17th, 2017 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.idc.cema.emp;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.List;
  6.  
  7. import org.junit.Before;
  8. import org.junit.Test;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.transaction.TransactionStatus;
  11. import org.springframework.transaction.support.TransactionCallback;
  12. import org.springframework.transaction.support.TransactionTemplate;
  13.  
  14. import com.idc.cema.emp.data.builder.EmployeeBuilder;
  15. import com.idc.cema.emp.data.builder.event.EventBuilder;
  16. import com.idc.cema.emp.domain.event.EmaEventSettings;
  17. import com.idc.cema.emp.domain.event.Event;
  18. import com.idc.cema.emp.domain.json.BasicAttendeeProperties;
  19. import com.idc.cema.emp.domain.json.enums.BasicAttendeeProperty;
  20. import com.idc.cema.emp.service.event.EventService;
  21. import com.idc.cema.emp.ui.EmpUI;
  22. import com.idc.cema.emp.ui.component.ViewTitleComponent;
  23. import com.idc.cema.emp.ui.component.event.panel.EventPanel;
  24. import com.idc.cema.emp.ui.component.event.panel.content.EventDetailPanelContent;
  25. import com.idc.cema.emp.ui.view.EmpView;
  26. import com.idc.cema.emp.ui.view.event.EventDetailView;
  27. import com.idc.cema.emp.util.explorer.ComponentFinder;
  28. import com.idc.cema.emp.util.explorer.MenuItemFinderByText;
  29. import com.vaadin.navigator.Navigator;
  30. import com.vaadin.navigator.ViewChangeListener;
  31. import com.vaadin.ui.Component;
  32. import com.vaadin.ui.HorizontalLayout;
  33. import com.vaadin.ui.Label;
  34. import com.vaadin.ui.MenuBar;
  35. import com.vaadin.ui.TextField;
  36. import com.vaadin.ui.VerticalLayout;
  37.  
  38. import static ch.lambdaj.Lambda.having;
  39. import static ch.lambdaj.Lambda.on;
  40. import static ch.lambdaj.Lambda.selectFirst;
  41.  
  42. import static org.hamcrest.Matchers.is;
  43.  
  44. import static org.junit.Assert.assertThat;
  45.  
  46. /**
  47.  * TODO CLASS COMMENT !!!
  48.  */
  49. public class EmaSettingsTest  extends VaadinApplicationTest {
  50.  
  51.     private static final String NEW_EVENT_NAME = "XXX";
  52.  
  53.     @Autowired
  54.     private EventDetailView eventDetailView;
  55.  
  56.     private TransactionTemplate txTemplate;
  57.  
  58.     @Autowired
  59.     private EventService eventService;
  60.  
  61.     @Before
  62.     public void setUp() throws Exception {
  63.         txTemplate = new TransactionTemplate(transactionManager);
  64.     }
  65.  
  66.  
  67.     @Test
  68.     public void eventSaveEmaSettings() {
  69.         authenticateUser(EmployeeBuilder.USER_WITH_EXTERNAL_CONFERENCES_RIGHTS);
  70.  
  71.         final Event event = txTemplate.execute(new TransactionCallback<Event>() {
  72.             @Override
  73.             public Event doInTransaction(TransactionStatus status) {
  74.                 return createBuilder(EventBuilder.class).withDefaults("eventRename").persist().build();
  75.             }
  76.         });
  77.  
  78.  
  79.         BasicAttendeeProperties basicAttendeeProperties = new BasicAttendeeProperties();
  80.         basicAttendeeProperties.setValues(new ArrayList<BasicAttendeeProperty>(Arrays.asList(BasicAttendeeProperty.NAME, BasicAttendeeProperty.PICTURE, BasicAttendeeProperty.COMPANY)));
  81.  
  82.         EmaEventSettings emaEventSettings = event.getEmaEventSettings();
  83.  
  84.         if (emaEventSettings == null) {
  85.             emaEventSettings = new EmaEventSettings();
  86.             emaEventSettings.setId(event.getProductId());
  87.             event.setEmaEventSettings(emaEventSettings);
  88.         }
  89.         emaEventSettings.setBasicAttendeeProperties(basicAttendeeProperties);
  90.  
  91.         eventService.save(event);
  92.     }
  93.  
  94.     @Test
  95.     public void eventUpdateEmaSettings() {
  96.         authenticateUser(EmployeeBuilder.USER_WITH_EXTERNAL_CONFERENCES_RIGHTS);
  97.  
  98. Event event = eventService.getOne(57101L);
  99.  
  100.         BasicAttendeeProperties basicAttendeeProperties = new BasicAttendeeProperties();
  101.         basicAttendeeProperties.setValues(new ArrayList<BasicAttendeeProperty>(Arrays.asList(BasicAttendeeProperty.NAME, BasicAttendeeProperty.PICTURE, BasicAttendeeProperty.COMPANY)));
  102.  
  103.         EmaEventSettings emaEventSettings = event.getEmaEventSettings();
  104.  
  105.         if (emaEventSettings == null) {
  106.             emaEventSettings = new EmaEventSettings();
  107.             emaEventSettings.setId(event.getProductId());
  108.             event.setEmaEventSettings(emaEventSettings);
  109.         }
  110.         emaEventSettings.setBasicAttendeeProperties(basicAttendeeProperties);
  111.  
  112.         eventService.save(event);
  113.     }
  114.  
  115.  
  116.  
  117.  
  118. }
RAW Paste Data
Pastebin PRO Summer Special!
Get 60% OFF on Pastebin PRO accounts!
Top