@@ -0,0 +1,3528 @@
+package org.openlmis.web.controller; %0A%0Aimport org.junit.Before;%0Aimport org.junit.After;%0Aimport org.junit.Test;%0Aimport org.junit.experimental.categories.Category;%0Aimport org.junit.runner.RunWith;%0Aimport org.mockito.InjectMocks;%0Aimport org.mockito.Mock;%0Aimport org.openlmis.core.domain.ConfigurationSetting;%0Aimport org.openlmis.core.service.ConfigurationSettingService;%0Aimport org.openlmis.db.categories.UnitTests;%0Aimport org.openlmis.report.model.dto.Product;%0Aimport org.openlmis.web.model.ConfigurationDTO;%0Aimport org.openlmis.web.response.OpenLmisResponse;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.PowerMockRunner;%0Aimport org.springframework.http.HttpStatus;%0Aimport org.springframework.http.ResponseEntity;%0Aimport org.springframework.mock.web.MockHttpServletRequest;%0Aimport org.springframework.mock.web.MockHttpSession;%0A%0Aimport java.security.Principal;%0Aimport java.util.ArrayList;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.mockito.Mockito.*;%0Aimport static org.mockito.MockitoAnnotations.initMocks;%0Aimport static org.openlmis.web.response.OpenLmisResponse.SUCCESS;%0Aimport static org.powermock.api.mockito.PowerMockito.mockStatic;%0A%0A@RunWith(PowerMockRunner.class)%0A@PrepareForTest(OpenLmisResponse.class)%0A@Category(UnitTests.class)%0Apublic class SettingControllerTest %7B%0A%0A  private Long userId;%0A%0A  private MockHttpSession session;%0A%0A  private MockHttpServletRequest httpServletRequest;%0A%0A%0A  @Mock%0A  private ConfigurationSettingService configurationService;%0A%0A  @InjectMocks%0A  private SettingController controller;%0A%0A  @Before%0A  public void setup()%7B%0A    initMocks(this);%0A    userId = 3L;%0A    httpServletRequest = new MockHttpServletRequest();%0A    session = new MockHttpSession();%0A    httpServletRequest.setSession(session);%0A    mockStatic(OpenLmisResponse.class);%0A  %7D%0A%0A%0A  @Test%0A  public void shouldGetAllSettings() throws Exception %7B%0A    ArrayList%3CConfigurationSetting%3E configSettingList = new ArrayList%3CConfigurationSetting%3E();%0A    configSettingList.add(new ConfigurationSetting());%0A%0A    ConfigurationDTO dto = new ConfigurationDTO();%0A    dto.setList(configSettingList);%0A%0A    when(configurationService.getConfigurations()).thenReturn(configSettingList);%0A%0A    ResponseEntity%3COpenLmisResponse%3E expectResponse = new ResponseEntity%3C%3E(new OpenLmisResponse(), HttpStatus.OK);%0A    when(OpenLmisResponse.response(%22settings%22, dto)).thenReturn(expectResponse);%0A%0A    ResponseEntity%3COpenLmisResponse%3E response = controller.getAll();%0A%0A    verify(configurationService).getConfigurations();%0A    assertThat(response, is(expectResponse));%0A  %7D%0A%0A%0A  @Test%0A  public void shouldGetSettingByKey() throws Exception %7B%0A    ConfigurationSetting setting = new ConfigurationSetting();%0A%0A    when(configurationService.getByKey(%22123%22)).thenReturn(setting);%0A%0A    ResponseEntity%3COpenLmisResponse%3E expectResponse = new ResponseEntity%3C%3E(new OpenLmisResponse(), HttpStatus.OK);%0A    when(OpenLmisResponse.response(%22settings%22, setting)).thenReturn(expectResponse);%0A%0A    ResponseEntity%3COpenLmisResponse%3E response = controller.getByKey(%22123%22);%0A%0A    verify(configurationService).getByKey(%22123%22);%0A    assertThat(response, is(expectResponse));%0A  %7D%0A%0A%0A  @Test%0A  public void shouldUpdateSettings() throws Exception %7B%0A    ConfigurationDTO configurationDTO = new ConfigurationDTO();%0A    ResponseEntity%3COpenLmisResponse%3E responseEntity = controller.updateSettings(configurationDTO);%0A    verify(configurationService).update(configurationDTO.getList());%0A  %7D%0A%0A%0A%7D %0A

add tests for settings controller