@@ -0,0 +1,3604 @@
+/*%0A * This program was produced for the U.S. Agency for International Development. It was prepared by the USAID %7C DELIVER PROJECT, Task Order 4. It is part of a project which utilizes code originally licensed under the terms of the Mozilla Public License (MPL) v2 and therefore is licensed under MPL v2 or later.%0A *%0A * This program is free software: you can redistribute it and/or modify it under the terms of the Mozilla Public License as published by the Mozilla Foundation, either version 2 of the License, or (at your option) any later version.%0A *%0A * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public License for more details.%0A *%0A * You should have received a copy of the Mozilla Public License along with this program. If not, see http://www.mozilla.org/MPL/%0A */%0A%0Apackage org.openlmis.core.repository.mapper;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.experimental.categories.Category;%0Aimport org.junit.runner.RunWith;%0Aimport org.openlmis.core.domain.ConfigurationSetting;%0Aimport org.openlmis.core.query.QueryExecutor;%0Aimport org.openlmis.db.categories.IntegrationTests;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.test.context.ContextConfiguration;%0Aimport org.springframework.test.context.junit4.SpringJUnit4ClassRunner;%0Aimport org.springframework.test.context.transaction.TransactionConfiguration;%0Aimport org.springframework.transaction.annotation.Transactional;%0A%0Aimport java.sql.ResultSet;%0Aimport java.util.List;%0A%0Aimport static junit.framework.Assert.assertEquals;%0A%0A@Category(IntegrationTests.class)%0A@ContextConfiguration(locations = %22classpath:test-applicationContext-core.xml%22)%0A@RunWith(SpringJUnit4ClassRunner.class)%0A@Transactional%0A@TransactionConfiguration(defaultRollback = true, transactionManager = %22openLmisTransactionManager%22)%0Apublic class ConfigurationSettingMapperIT %7B%0A%0A  public static final String COUNTRY_KEY = %22COUNTRY%22;%0A%0A  @Autowired%0A  private ConfigurationSettingMapper mapper;%0A%0A  @Autowired%0A  private QueryExecutor queryExecutor;%0A%0A  @Before%0A  public void setUp() throws Exception %7B%0A%0A  %7D%0A%0A  @Test%0A  public void shouldGetByKey() throws Exception %7B%0A    ConfigurationSetting setting = mapper.getByKey(COUNTRY_KEY);%0A    assertEquals(setting.getKey(), COUNTRY_KEY);%0A  %7D%0A%0A  @Test%0A  public void shouldGetAll() throws Exception %7B%0A    ResultSet resultSet = queryExecutor.execute(%22select count(*) count from configuration_settings%22);%0A    resultSet.next();%0A    int expectedCount = resultSet.getInt(%22count%22);%0A%0A    List%3CConfigurationSetting%3E settings = mapper.getAll();%0A%0A    assertEquals(settings.size(), expectedCount);%0A  %7D%0A%0A  @Test%0A  public void shouldGetAllVerifyFirstAndLastElements() throws Exception %7B%0A    ResultSet resultSet = queryExecutor.execute(%22select * from configuration_settings order by groupName, displayOrder, name%22);%0A    resultSet.next();%0A    String expectedFirstKey = resultSet.getString(%22key%22);%0A%0A    List%3CConfigurationSetting%3E settings = mapper.getAll();%0A%0A    assertEquals(settings.get(0).getKey(), expectedFirstKey);%0A  %7D%0A%0A  @Test%0A  public void shouldUpdateValue() throws Exception %7B%0A    queryExecutor.executeUpdate(%22update configuration_settings set value = '123' where key = 'COUNTRY' %22);%0A%0A    ConfigurationSetting setting = mapper.getByKey(COUNTRY_KEY);%0A    setting.setValue(%22234%22);%0A    mapper.updateValue(setting);%0A%0A    ConfigurationSetting updatedSetting = mapper.getByKey(COUNTRY_KEY);%0A    assertEquals(%22234%22, updatedSetting.getValue());%0A  %7D%0A%7D%0A

Add unit tests for ConfigurationSettingMapper