=== removed directory 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc' === removed directory 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler' === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/CompleteDataSetRegistrationBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/CompleteDataSetRegistrationBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/CompleteDataSetRegistrationBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,225 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.hisp.dhis.dataset.CompleteDataSetRegistration; -import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; -import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.dataset.DataSetService; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.period.MonthlyPeriodType; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.period.PeriodService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Collection; -import java.util.Date; - -import static org.junit.Assert.*; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class CompleteDataSetRegistrationBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private DataSetService dataSetService; - - @Autowired - private PeriodService periodService; - - @Autowired - private OrganisationUnitService organisationUnitService; - - @Autowired - private CompleteDataSetRegistrationService completeDataSetRegistrationService; - - @Autowired - private DataElementCategoryService categoryService; - - private BatchHandler batchHandler; - - private DataSet dataSetA; - - private DataSet dataSetB; - - private Period periodA; - - private Period periodB; - - private OrganisationUnit unitA; - - private DataElementCategoryOptionCombo optionCombo; - - private Date dateA; - - private Date dateB; - - private CompleteDataSetRegistration registrationA; - - private CompleteDataSetRegistration registrationB; - - private CompleteDataSetRegistration registrationC; - - private CompleteDataSetRegistration registrationD; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( CompleteDataSetRegistrationBatchHandler.class ); - - dataSetA = createDataSet( 'A', new MonthlyPeriodType() ); - dataSetB = createDataSet( 'B', new MonthlyPeriodType() ); - - dataSetService.addDataSet( dataSetA ); - dataSetService.addDataSet( dataSetB ); - - periodA = createPeriod( new MonthlyPeriodType(), getDate( 2000, 1, 1 ), getDate( 2000, 1, 31 ) ); - periodB = createPeriod( new MonthlyPeriodType(), getDate( 2000, 2, 1 ), getDate( 2000, 2, 28 ) ); - - periodService.addPeriod( periodA ); - periodService.addPeriod( periodB ); - - unitA = createOrganisationUnit( 'A' ); - - organisationUnitService.addOrganisationUnit( unitA ); - - optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo(); - - dateA = getDate( 2000, 1, 15 ); - dateB = getDate( 2000, 2, 15 ); - - registrationA = new CompleteDataSetRegistration( dataSetA, periodA, unitA, optionCombo, dateA, ""); - registrationB = new CompleteDataSetRegistration( dataSetA, periodB, unitA, optionCombo, dateB, ""); - registrationC = new CompleteDataSetRegistration( dataSetB, periodA, unitA, optionCombo, dateA, ""); - registrationD = new CompleteDataSetRegistration( dataSetB, periodB, unitA, optionCombo, dateB, ""); - - batchHandler.init(); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( registrationA ); - batchHandler.addObject( registrationB ); - batchHandler.addObject( registrationC ); - batchHandler.addObject( registrationD ); - - batchHandler.flush(); - - Collection registrations = completeDataSetRegistrationService - .getAllCompleteDataSetRegistrations(); - - assertNotNull( registrations ); - assertEquals( 4, registrations.size() ); - - assertTrue( registrations.contains( registrationA ) ); - assertTrue( registrations.contains( registrationB ) ); - assertTrue( registrations.contains( registrationC ) ); - assertTrue( registrations.contains( registrationD ) ); - } - - @Test - public void testInsertObject() - { - batchHandler.insertObject( registrationA, false ); - batchHandler.insertObject( registrationB, false ); - batchHandler.insertObject( registrationC, false ); - batchHandler.insertObject( registrationD, false ); - - assertNotNull( completeDataSetRegistrationService - .getCompleteDataSetRegistration( dataSetA, periodA, unitA, optionCombo ) ); - assertNotNull( completeDataSetRegistrationService - .getCompleteDataSetRegistration( dataSetA, periodB, unitA, optionCombo ) ); - assertNotNull( completeDataSetRegistrationService - .getCompleteDataSetRegistration( dataSetB, periodA, unitA, optionCombo ) ); - assertNotNull( completeDataSetRegistrationService - .getCompleteDataSetRegistration( dataSetB, periodB, unitA, optionCombo ) ); - } - - @Test - public void testUpdateObject() - { - batchHandler.insertObject( registrationA, false ); - - registrationA.setDate( dateB ); - - batchHandler.updateObject( registrationA ); - - registrationA = completeDataSetRegistrationService - .getCompleteDataSetRegistration( dataSetA, periodA, unitA, optionCombo ); - - assertEquals( dateB, registrationA.getDate() ); - } - - @Test - public void testObjectExists() - { - completeDataSetRegistrationService.saveCompleteDataSetRegistration( registrationA ); - completeDataSetRegistrationService.saveCompleteDataSetRegistration( registrationB ); - - assertTrue( batchHandler.objectExists( registrationA ) ); - assertTrue( batchHandler.objectExists( registrationB ) ); - - assertFalse( batchHandler.objectExists( registrationC ) ); - assertFalse( batchHandler.objectExists( registrationD ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataDictionaryBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataDictionaryBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataDictionaryBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,158 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.datadictionary.DataDictionary; -import org.hisp.dhis.datadictionary.DataDictionaryService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class DataDictionaryBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private DataDictionaryService dataDictionaryService ; - - private BatchHandler batchHandler; - - private DataDictionary dataDictionaryA; - private DataDictionary dataDictionaryB; - private DataDictionary dataDictionaryC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - - batchHandler = batchHandlerFactory.createBatchHandler( DataDictionaryBatchHandler.class ); - - batchHandler.init(); - - dataDictionaryA = createDataDictionary( 'A' ); - dataDictionaryB = createDataDictionary( 'B' ); - dataDictionaryC = createDataDictionary( 'C' ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( dataDictionaryA ); - batchHandler.addObject( dataDictionaryB ); - batchHandler.addObject( dataDictionaryC ); - - batchHandler.flush(); - - Collection dataDictionaries = dataDictionaryService.getAllDataDictionaries(); - - assertTrue( dataDictionaries.contains( dataDictionaryA ) ); - assertTrue( dataDictionaries.contains( dataDictionaryB ) ); - assertTrue( dataDictionaries.contains( dataDictionaryC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( dataDictionaryA, true ); - int idB = batchHandler.insertObject( dataDictionaryB, true ); - int idC = batchHandler.insertObject( dataDictionaryC, true ); - - assertNotNull( dataDictionaryService.getDataDictionary( idA ) ); - assertNotNull( dataDictionaryService.getDataDictionary( idB ) ); - assertNotNull( dataDictionaryService.getDataDictionary( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( dataDictionaryA, true ); - - dataDictionaryA.setId( id ); - dataDictionaryA.setName( "UpdatedName" ); - - batchHandler.updateObject( dataDictionaryA ); - - assertEquals( "UpdatedName", dataDictionaryService.getDataDictionary( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = dataDictionaryService.saveDataDictionary( dataDictionaryA ); - - int retrievedId = batchHandler.getObjectIdentifier( "DataDictionaryA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - dataDictionaryService.saveDataDictionary( dataDictionaryA ); - - assertTrue( batchHandler.objectExists( dataDictionaryA ) ); - - assertFalse( batchHandler.objectExists( dataDictionaryB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,188 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.cache.HibernateCacheManager; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryCombo; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.hisp.dhis.dataelement.DataElementService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id: DataElementBatchHandlerTest.java 4999 2008-04-23 15:45:08Z larshelg $ - */ -public class DataElementBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private HibernateCacheManager cacheManager; - - @Autowired - private DataElementCategoryService categoryService; - - @Autowired - private DataElementService dataElementService; - - private BatchHandler batchHandler; - - private DataElementCategoryCombo categoryCombo; - - private DataElement dataElementA; - private DataElement dataElementB; - private DataElement dataElementC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( DataElementBatchHandler.class ); - - categoryCombo = categoryService.getDataElementCategoryComboByName( DataElementCategoryCombo.DEFAULT_CATEGORY_COMBO_NAME ); - - batchHandler.init(); - - dataElementA = createDataElement( 'A', categoryCombo ); - dataElementB = createDataElement( 'B', categoryCombo ); - dataElementC = createDataElement( 'C', categoryCombo ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( dataElementA ); - batchHandler.addObject( dataElementB ); - batchHandler.addObject( dataElementC ); - - batchHandler.flush(); - - cacheManager.clearCache(); - - Collection dataElements = dataElementService.getAllDataElements(); - - assertTrue( dataElements.contains( dataElementA ) ); - assertTrue( dataElements.contains( dataElementB ) ); - assertTrue( dataElements.contains( dataElementC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( dataElementA, true ); - int idB = batchHandler.insertObject( dataElementB, true ); - int idC = batchHandler.insertObject( dataElementC, true ); - - cacheManager.clearCache(); - - assertNotNull( dataElementService.getDataElement( idA ) ); - assertNotNull( dataElementService.getDataElement( idB ) ); - assertNotNull( dataElementService.getDataElement( idC ) ); - } - - @Test - public void testInsertWithSpecialCharacters() - { - dataElementA.setDescription( "'quote'" ); - dataElementB.setDescription( "\\backslash\\" ); - dataElementC.setDescription( ";semicolon;" ); - - batchHandler.insertObject( dataElementA, false ); - batchHandler.insertObject( dataElementB, false ); - batchHandler.insertObject( dataElementC, false ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( dataElementA, true ); - - dataElementA.setId( id ); - dataElementA.setName( "UpdatedName" ); - - batchHandler.updateObject( dataElementA ); - - cacheManager.clearCache(); - - assertEquals( "UpdatedName", dataElementService.getDataElement( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = dataElementService.addDataElement( dataElementA ); - - int retrievedId = batchHandler.getObjectIdentifier( "DataElementA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - dataElementService.addDataElement( dataElementA ); - - assertTrue( batchHandler.objectExists( dataElementA ) ); - - assertFalse( batchHandler.objectExists( dataElementB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementCategoryBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementCategoryBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementCategoryBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,161 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.dataelement.DataElementCategory; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.junit.Ignore; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class DataElementCategoryBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private DataElementCategoryService categoryService; - - private BatchHandler batchHandler; - - private DataElementCategory categoryA; - private DataElementCategory categoryB; - private DataElementCategory categoryC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryBatchHandler.class ); - - batchHandler.init(); - - categoryA = new DataElementCategory( "CategoryA" ); - categoryB = new DataElementCategory( "CategoryB" ); - categoryC = new DataElementCategory( "CategoryC" ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Ignore - @Test - public void testAddObject() - { - batchHandler.addObject( categoryA ); - batchHandler.addObject( categoryB ); - batchHandler.addObject( categoryC ); - - batchHandler.flush(); - - Collection categories = categoryService.getAllDataElementCategories(); - - assertTrue( categories.contains( categoryA ) ); - assertTrue( categories.contains( categoryB ) ); - assertTrue( categories.contains( categoryC ) ); - } - - @Ignore - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( categoryA, true ); - int idB = batchHandler.insertObject( categoryB, true ); - int idC = batchHandler.insertObject( categoryC, true ); - - assertNotNull( categoryService.getDataElementCategory( idA ) ); - assertNotNull( categoryService.getDataElementCategory( idB ) ); - assertNotNull( categoryService.getDataElementCategory( idC ) ); - } - - @Ignore - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( categoryA, true ); - - categoryA.setId( id ); - categoryA.setName( "updatedName" ); - - batchHandler.updateObject( categoryA ); - - assertEquals( "updatedName", categoryService.getDataElementCategory( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = categoryService.addDataElementCategory( categoryA ); - - int retrievedId = batchHandler.getObjectIdentifier( "CategoryA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - categoryService.addDataElementCategory( categoryA ); - - assertTrue( batchHandler.objectExists( categoryA ) ); - - assertFalse( batchHandler.objectExists( categoryB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementCategoryComboBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementCategoryComboBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementCategoryComboBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.dataelement.DataElementCategoryCombo; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class DataElementCategoryComboBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private DataElementCategoryService categoryService; - - private BatchHandler batchHandler; - - private DataElementCategoryCombo categoryComboA; - private DataElementCategoryCombo categoryComboB; - private DataElementCategoryCombo categoryComboC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryComboBatchHandler.class ); - - batchHandler.init(); - - categoryComboA = new DataElementCategoryCombo( "CategoryComboA" ); - categoryComboB = new DataElementCategoryCombo( "CategoryComboB" ); - categoryComboC = new DataElementCategoryCombo( "CategoryComboC" ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( categoryComboA ); - batchHandler.addObject( categoryComboB ); - batchHandler.addObject( categoryComboC ); - - batchHandler.flush(); - - Collection categoryCombos = categoryService.getAllDataElementCategoryCombos(); - - assertTrue( categoryCombos.contains( categoryComboA ) ); - assertTrue( categoryCombos.contains( categoryComboB ) ); - assertTrue( categoryCombos.contains( categoryComboC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( categoryComboA, true ); - int idB = batchHandler.insertObject( categoryComboB, true ); - int idC = batchHandler.insertObject( categoryComboC, true ); - - assertNotNull( categoryService.getDataElementCategoryCombo( idA ) ); - assertNotNull( categoryService.getDataElementCategoryCombo( idB ) ); - assertNotNull( categoryService.getDataElementCategoryCombo( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( categoryComboA, true ); - - categoryComboA.setId( id ); - categoryComboA.setName( "UpdatedName" ); - - batchHandler.updateObject( categoryComboA ); - - assertEquals( "UpdatedName", categoryService.getDataElementCategoryCombo( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = categoryService.addDataElementCategoryCombo( categoryComboA ); - - int retrievedId = batchHandler.getObjectIdentifier( "CategoryComboA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - categoryService.addDataElementCategoryCombo( categoryComboA ); - - assertTrue( batchHandler.objectExists( categoryComboA ) ); - - assertFalse( batchHandler.objectExists( categoryComboB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementCategoryOptionBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementCategoryOptionBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementCategoryOptionBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.dataelement.DataElementCategoryOption; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class DataElementCategoryOptionBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private DataElementCategoryService categoryService; - - private BatchHandler batchHandler; - - private DataElementCategoryOption categoryOptionA; - private DataElementCategoryOption categoryOptionB; - private DataElementCategoryOption categoryOptionC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( DataElementCategoryOptionBatchHandler.class ); - - batchHandler.init(); - - categoryOptionA = new DataElementCategoryOption( "CategoryOptionA" ); - categoryOptionB = new DataElementCategoryOption( "CategoryOptionB" ); - categoryOptionC = new DataElementCategoryOption( "CategoryOptionC" ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( categoryOptionA ); - batchHandler.addObject( categoryOptionB ); - batchHandler.addObject( categoryOptionC ); - - batchHandler.flush(); - - Collection categoryOptions = categoryService.getAllDataElementCategoryOptions(); - - assertTrue( categoryOptions.contains( categoryOptionA ) ); - assertTrue( categoryOptions.contains( categoryOptionB ) ); - assertTrue( categoryOptions.contains( categoryOptionC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( categoryOptionA, true ); - int idB = batchHandler.insertObject( categoryOptionB, true ); - int idC = batchHandler.insertObject( categoryOptionC, true ); - - assertNotNull( categoryService.getDataElementCategoryOption( idA ) ); - assertNotNull( categoryService.getDataElementCategoryOption( idB ) ); - assertNotNull( categoryService.getDataElementCategoryOption( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( categoryOptionA, true ); - - categoryOptionA.setId( id ); - categoryOptionA.setName( "UpdatedName" ); - - batchHandler.updateObject( categoryOptionA ); - - assertEquals( "UpdatedName", categoryService.getDataElementCategoryOption( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = categoryService.addDataElementCategoryOption( categoryOptionA ); - - int retrievedId = batchHandler.getObjectIdentifier( "CategoryOptionA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - categoryService.addDataElementCategoryOption( categoryOptionA ); - - assertTrue( batchHandler.objectExists( categoryOptionA ) ); - - assertFalse( batchHandler.objectExists( categoryOptionB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementGroupBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementGroupBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementGroupBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.dataelement.DataElementGroup; -import org.hisp.dhis.dataelement.DataElementService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id: DataElementGroupBatchHandlerTest.java 4949 2008-04-21 07:59:54Z larshelg $ - */ -public class DataElementGroupBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private DataElementService dataElementService; - - private BatchHandler batchHandler; - - private DataElementGroup groupA; - private DataElementGroup groupB; - private DataElementGroup groupC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupBatchHandler.class ); - - batchHandler.init(); - - groupA = createDataElementGroup( 'A' ); - groupB = createDataElementGroup( 'B' ); - groupC = createDataElementGroup( 'C' ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( groupA ); - batchHandler.addObject( groupB ); - batchHandler.addObject( groupC ); - - batchHandler.flush(); - - Collection groups = dataElementService.getAllDataElementGroups(); - - assertTrue( groups.contains( groupA ) ); - assertTrue( groups.contains( groupB ) ); - assertTrue( groups.contains( groupC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( groupA, true ); - int idB = batchHandler.insertObject( groupB, true ); - int idC = batchHandler.insertObject( groupC, true ); - - assertNotNull( dataElementService.getDataElementGroup( idA ) ); - assertNotNull( dataElementService.getDataElementGroup( idB ) ); - assertNotNull( dataElementService.getDataElementGroup( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( groupA, true ); - - groupA.setId( id ); - groupA.setName( "UpdatedName" ); - - batchHandler.updateObject( groupA ); - - assertEquals( "UpdatedName", dataElementService.getDataElementGroup( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = dataElementService.addDataElementGroup( groupA ); - - int retrievedId = batchHandler.getObjectIdentifier( "DataElementGroupA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - dataElementService.addDataElementGroup( groupA ); - - assertTrue( batchHandler.objectExists( groupA ) ); - - assertFalse( batchHandler.objectExists( groupB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementGroupSetBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementGroupSetBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataElementGroupSetBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.dataelement.DataElementGroupSet; -import org.hisp.dhis.dataelement.DataElementService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class DataElementGroupSetBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private DataElementService dataElementService; - - private BatchHandler batchHandler; - - private DataElementGroupSet groupSetA; - private DataElementGroupSet groupSetB; - private DataElementGroupSet groupSetC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( DataElementGroupSetBatchHandler.class ); - - batchHandler.init(); - - groupSetA = createDataElementGroupSet( 'A' ); - groupSetB = createDataElementGroupSet( 'B' ); - groupSetC = createDataElementGroupSet( 'C' ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( groupSetA ); - batchHandler.addObject( groupSetB ); - batchHandler.addObject( groupSetC ); - - batchHandler.flush(); - - Collection groupsSets = dataElementService.getAllDataElementGroupSets(); - - assertTrue( groupsSets.contains( groupSetA ) ); - assertTrue( groupsSets.contains( groupSetB ) ); - assertTrue( groupsSets.contains( groupSetC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( groupSetA, true ); - int idB = batchHandler.insertObject( groupSetB, true ); - int idC = batchHandler.insertObject( groupSetC, true ); - - assertNotNull( dataElementService.getDataElementGroupSet( idA ) ); - assertNotNull( dataElementService.getDataElementGroupSet( idB ) ); - assertNotNull( dataElementService.getDataElementGroupSet( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( groupSetA, true ); - - groupSetA.setId( id ); - groupSetA.setName( "UpdatedName" ); - - batchHandler.updateObject( groupSetA ); - - assertEquals( "UpdatedName", dataElementService.getDataElementGroupSet( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = dataElementService.addDataElementGroupSet( groupSetA ); - - int retrievedId = batchHandler.getObjectIdentifier( "DataElementGroupSetA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - dataElementService.addDataElementGroupSet( groupSetA ); - - assertTrue( batchHandler.objectExists( groupSetA ) ); - - assertFalse( batchHandler.objectExists( groupSetB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataSetBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,162 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.dataset.DataSet; -import org.hisp.dhis.dataset.DataSetService; -import org.hisp.dhis.period.MonthlyPeriodType; -import org.hisp.dhis.period.PeriodService; -import org.hisp.dhis.period.PeriodType; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -import java.util.Collection; - -import static org.junit.Assert.*; - -/** - * @author Lars Helge Overland - * @version $Id: DataSetBatchHandlerTest.java 4949 2008-04-21 07:59:54Z larshelg $ - */ -public class DataSetBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private DataSetService dataSetService; - - @Autowired - private PeriodService periodService; - - private BatchHandler batchHandler; - - private DataSet dataSetA; - private DataSet dataSetB; - private DataSet dataSetC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( DataSetBatchHandler.class ); - - batchHandler.init(); - - PeriodType periodType = periodService.getPeriodTypeByName( MonthlyPeriodType.NAME ); - - dataSetA = createDataSet( 'A', periodType ); - dataSetB = createDataSet( 'B', periodType ); - dataSetC = createDataSet( 'C', periodType ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( dataSetA ); - batchHandler.addObject( dataSetB ); - batchHandler.addObject( dataSetC ); - - batchHandler.flush(); - - Collection dataSets = dataSetService.getAllDataSets(); - - assertTrue( dataSets.contains( dataSetA ) ); - assertTrue( dataSets.contains( dataSetB ) ); - assertTrue( dataSets.contains( dataSetC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( dataSetA, true ); - int idB = batchHandler.insertObject( dataSetB, true ); - int idC = batchHandler.insertObject( dataSetC, true ); - - assertNotNull( dataSetService.getDataSet( idA ) ); - assertNotNull( dataSetService.getDataSet( idB ) ); - assertNotNull( dataSetService.getDataSet( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( dataSetA, true ); - - dataSetA.setId( id ); - dataSetA.setName( "UpdatedName" ); - - batchHandler.updateObject( dataSetA ); - - assertEquals( "UpdatedName", dataSetService.getDataSet( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = dataSetService.addDataSet( dataSetA ); - - int retrievedId = batchHandler.getObjectIdentifier( "DataSetA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - dataSetService.addDataSet( dataSetA ); - - assertTrue( batchHandler.objectExists( dataSetA ) ); - - assertFalse( batchHandler.objectExists( dataSetB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/DataValueBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,214 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.dataelement.DataElement; -import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; -import org.hisp.dhis.dataelement.DataElementCategoryService; -import org.hisp.dhis.dataelement.DataElementService; -import org.hisp.dhis.datavalue.DataValue; -import org.hisp.dhis.datavalue.DataValueService; -import org.hisp.dhis.organisationunit.OrganisationUnit; -import org.hisp.dhis.organisationunit.OrganisationUnitService; -import org.hisp.dhis.period.MonthlyPeriodType; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.period.PeriodService; -import org.hisp.dhis.period.PeriodType; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class DataValueBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private DataValueService dataValueService; - - @Autowired - private DataElementService dataElementService; - - @Autowired - private DataElementCategoryService categoryService; - - @Autowired - private PeriodService periodService; - - @Autowired - private OrganisationUnitService organisationUnitService; - - private BatchHandler batchHandler; - - private DataElement dataElementA; - - private DataElementCategoryOptionCombo categoryOptionComboA; - - private PeriodType periodTypeA; - - private Period periodA; - private Period periodB; - - private OrganisationUnit unitA; - private OrganisationUnit unitB; - - private DataValue dataValueA; - private DataValue dataValueB; - private DataValue dataValueC; - private DataValue dataValueD; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( DataValueBatchHandler.class ); - - dataElementA = createDataElement( 'A' ); - - dataElementService.addDataElement( dataElementA ); - - categoryOptionComboA = categoryService.getDefaultDataElementCategoryOptionCombo(); - - periodTypeA = PeriodType.getPeriodTypeByName( MonthlyPeriodType.NAME ); - - periodA = createPeriod( periodTypeA, getDate( 2000, 0, 1 ), getDate( 2000, 0, 31 ) ); - periodB = createPeriod( periodTypeA, getDate( 2000, 1, 1 ), getDate( 2000, 2, 28 ) ); - - periodService.addPeriod( periodA ); - periodService.addPeriod( periodB ); - - unitA = createOrganisationUnit( 'A' ); - unitB = createOrganisationUnit( 'B' ); - - organisationUnitService.addOrganisationUnit( unitA ); - organisationUnitService.addOrganisationUnit( unitB ); - - dataValueA = createDataValue( dataElementA, periodA, unitA, "10", categoryOptionComboA, categoryOptionComboA ); - dataValueB = createDataValue( dataElementA, periodA, unitB, "10", categoryOptionComboA, categoryOptionComboA ); - dataValueC = createDataValue( dataElementA, periodB, unitA, "10", categoryOptionComboA, categoryOptionComboA ); - dataValueD = createDataValue( dataElementA, periodB, unitB, "10", categoryOptionComboA, categoryOptionComboA ); - - batchHandler.init(); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( dataValueA ); - batchHandler.addObject( dataValueB ); - batchHandler.addObject( dataValueC ); - batchHandler.addObject( dataValueD ); - - batchHandler.flush(); - - Collection values = dataValueService.getAllDataValues(); - - assertNotNull( values ); - assertEquals( 4, values.size() ); - - assertTrue( values.contains( dataValueA ) ); - assertTrue( values.contains( dataValueB ) ); - assertTrue( values.contains( dataValueC ) ); - assertTrue( values.contains( dataValueD ) ); - } - - @Test - public void testInsertObject() - { - batchHandler.insertObject( dataValueA, false ); - batchHandler.insertObject( dataValueB, false ); - batchHandler.insertObject( dataValueC, false ); - batchHandler.insertObject( dataValueD, false ); - - assertNotNull( dataValueService.getDataValue( dataElementA, periodA, unitA, categoryOptionComboA ) ); - assertNotNull( dataValueService.getDataValue( dataElementA, periodA, unitB, categoryOptionComboA ) ); - assertNotNull( dataValueService.getDataValue( dataElementA, periodB, unitA, categoryOptionComboA ) ); - assertNotNull( dataValueService.getDataValue( dataElementA, periodB, unitB, categoryOptionComboA ) ); - } - - @Test - public void testUpdateObject() - { - batchHandler.insertObject( dataValueA, false ); - - dataValueA.setValue( "20" ); - - batchHandler.updateObject( dataValueA ); - - dataValueA = dataValueService.getDataValue( dataElementA, periodA, unitA, categoryOptionComboA ); - - assertEquals( "20", dataValueA.getValue() ); - } - - @Test - public void testObjectExists() - { - dataValueService.addDataValue( dataValueA ); - dataValueService.addDataValue( dataValueC ); - - assertTrue( batchHandler.objectExists( dataValueA ) ); - assertTrue( batchHandler.objectExists( dataValueC ) ); - - assertFalse( batchHandler.objectExists( dataValueB ) ); - assertFalse( batchHandler.objectExists( dataValueD ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/GroupSetBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/GroupSetBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/GroupSetBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; -import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id: GroupSetBatchHandlerTest.java 4949 2008-04-21 07:59:54Z larshelg $ - */ -public class GroupSetBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private OrganisationUnitGroupService organisationUnitGroupService; - - private BatchHandler batchHandler; - - private OrganisationUnitGroupSet groupSetA; - private OrganisationUnitGroupSet groupSetB; - private OrganisationUnitGroupSet groupSetC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( GroupSetBatchHandler.class ); - - batchHandler.init(); - - groupSetA = createOrganisationUnitGroupSet( 'A' ); - groupSetB = createOrganisationUnitGroupSet( 'B' ); - groupSetC = createOrganisationUnitGroupSet( 'C' ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( groupSetA ); - batchHandler.addObject( groupSetB ); - batchHandler.addObject( groupSetC ); - - batchHandler.flush(); - - Collection groupSets = organisationUnitGroupService.getAllOrganisationUnitGroupSets(); - - assertTrue( groupSets.add( groupSetA ) ); - assertTrue( groupSets.add( groupSetB ) ); - assertTrue( groupSets.add( groupSetC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( groupSetA, true ); - int idB = batchHandler.insertObject( groupSetB, true ); - int idC = batchHandler.insertObject( groupSetC, true ); - - assertNotNull( organisationUnitGroupService.getOrganisationUnitGroupSet( idA ) ); - assertNotNull( organisationUnitGroupService.getOrganisationUnitGroupSet( idB ) ); - assertNotNull( organisationUnitGroupService.getOrganisationUnitGroupSet( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( groupSetA, true ); - - groupSetA.setId( id ); - groupSetA.setName( "UpdatedName" ); - - batchHandler.updateObject( groupSetA ); - - assertEquals( "UpdatedName", organisationUnitGroupService.getOrganisationUnitGroupSet( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = organisationUnitGroupService.addOrganisationUnitGroupSet( groupSetA ); - - int retrievedId = batchHandler.getObjectIdentifier( "OrganisationUnitGroupSetA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - organisationUnitGroupService.addOrganisationUnitGroupSet( groupSetA ); - - assertTrue( batchHandler.objectExists( groupSetA ) ); - - assertFalse( batchHandler.objectExists( groupSetB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,172 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.cache.HibernateCacheManager; -import org.hisp.dhis.indicator.Indicator; -import org.hisp.dhis.indicator.IndicatorService; -import org.hisp.dhis.indicator.IndicatorType; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id: IndicatorBatchHandlerTest.java 4949 2008-04-21 07:59:54Z larshelg $ - */ -public class IndicatorBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private HibernateCacheManager cacheManager; - - @Autowired - private IndicatorService indicatorService; - - private BatchHandler batchHandler; - - private Indicator indicatorA; - private Indicator indicatorB; - private Indicator indicatorC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( IndicatorBatchHandler.class ); - - batchHandler.init(); - - IndicatorType indicatorType = createIndicatorType( 'A' ); - - indicatorService.addIndicatorType( indicatorType ); - - indicatorA = createIndicator( 'A', indicatorType ); - indicatorB = createIndicator( 'B', indicatorType ); - indicatorC = createIndicator( 'C', indicatorType ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( indicatorA ); - batchHandler.addObject( indicatorB ); - batchHandler.addObject( indicatorC ); - - batchHandler.flush(); - - cacheManager.clearCache(); - - Collection indicators = indicatorService.getAllIndicators(); - - assertTrue( indicators.contains( indicatorA ) ); - assertTrue( indicators.contains( indicatorB ) ); - assertTrue( indicators.contains( indicatorC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( indicatorA, true ); - int idB = batchHandler.insertObject( indicatorB, true ); - int idC = batchHandler.insertObject( indicatorC, true ); - - cacheManager.clearCache(); - - assertNotNull( indicatorService.getIndicator( idA ) ); - assertNotNull( indicatorService.getIndicator( idB ) ); - assertNotNull( indicatorService.getIndicator( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( indicatorA, true ); - - indicatorA.setId( id ); - indicatorA.setName( "UpdatedName" ); - - batchHandler.updateObject( indicatorA ); - - cacheManager.clearCache(); - - assertEquals( "UpdatedName", indicatorService.getIndicator( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = indicatorService.addIndicator( indicatorA ); - - int retrievedId = batchHandler.getObjectIdentifier( "IndicatorA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - indicatorService.addIndicator( indicatorA ); - - assertTrue( batchHandler.objectExists( indicatorA ) ); - - assertFalse( batchHandler.objectExists( indicatorB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorGroupBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorGroupBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorGroupBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.indicator.IndicatorGroup; -import org.hisp.dhis.indicator.IndicatorService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id: IndicatorGroupBatchHandlerTest.java 4949 2008-04-21 07:59:54Z larshelg $ - */ -public class IndicatorGroupBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private IndicatorService indicatorService; - - private BatchHandler batchHandler; - - private IndicatorGroup groupA; - private IndicatorGroup groupB; - private IndicatorGroup groupC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupBatchHandler.class ); - - batchHandler.init(); - - groupA = createIndicatorGroup( 'A' ); - groupB = createIndicatorGroup( 'B' ); - groupC = createIndicatorGroup( 'C' ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( groupA ); - batchHandler.addObject( groupB ); - batchHandler.addObject( groupC ); - - batchHandler.flush(); - - Collection groups = indicatorService.getAllIndicatorGroups(); - - assertTrue( groups.contains( groupA ) ); - assertTrue( groups.contains( groupB ) ); - assertTrue( groups.contains( groupC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( groupA, true ); - int idB = batchHandler.insertObject( groupB, true ); - int idC = batchHandler.insertObject( groupC, true ); - - assertNotNull( indicatorService.getIndicatorGroup( idA ) ); - assertNotNull( indicatorService.getIndicatorGroup( idB ) ); - assertNotNull( indicatorService.getIndicatorGroup( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( groupA, true ); - - groupA.setId( id ); - groupA.setName( "UpdatedName" ); - - batchHandler.updateObject( groupA ); - - assertEquals( "UpdatedName", indicatorService.getIndicatorGroup( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = indicatorService.addIndicatorGroup( groupA ); - - int retrievedId = batchHandler.getObjectIdentifier( "IndicatorGroupA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - indicatorService.addIndicatorGroup( groupA ); - - assertTrue( batchHandler.objectExists( groupA ) ); - - assertFalse( batchHandler.objectExists( groupB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorGroupSetBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorGroupSetBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorGroupSetBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.indicator.IndicatorGroupSet; -import org.hisp.dhis.indicator.IndicatorService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id$ - */ -public class IndicatorGroupSetBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private IndicatorService indicatorService; - - private BatchHandler batchHandler; - - private IndicatorGroupSet groupSetA; - private IndicatorGroupSet groupSetB; - private IndicatorGroupSet groupSetC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( IndicatorGroupSetBatchHandler.class ); - - batchHandler.init(); - - groupSetA = createIndicatorGroupSet( 'A' ); - groupSetB = createIndicatorGroupSet( 'B' ); - groupSetC = createIndicatorGroupSet( 'C' ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( groupSetA ); - batchHandler.addObject( groupSetB ); - batchHandler.addObject( groupSetC ); - - batchHandler.flush(); - - Collection groupSets = indicatorService.getAllIndicatorGroupSets(); - - assertTrue( groupSets.contains( groupSetA ) ); - assertTrue( groupSets.contains( groupSetB ) ); - assertTrue( groupSets.contains( groupSetC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( groupSetA, true ); - int idB = batchHandler.insertObject( groupSetB, true ); - int idC = batchHandler.insertObject( groupSetC, true ); - - assertNotNull( indicatorService.getIndicatorGroupSet( idA ) ); - assertNotNull( indicatorService.getIndicatorGroupSet( idB ) ); - assertNotNull( indicatorService.getIndicatorGroupSet( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( groupSetA, true ); - - groupSetA.setId( id ); - groupSetA.setName( "UpdatedName" ); - - batchHandler.updateObject( groupSetA ); - - assertEquals( "UpdatedName", indicatorService.getIndicatorGroupSet( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = indicatorService.addIndicatorGroupSet( groupSetA ); - - int retrievedId = batchHandler.getObjectIdentifier( "IndicatorGroupSetA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - indicatorService.addIndicatorGroupSet( groupSetA ); - - assertTrue( batchHandler.objectExists( groupSetA ) ); - - assertFalse( batchHandler.objectExists( groupSetB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorTypeBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorTypeBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/IndicatorTypeBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,157 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.indicator.IndicatorService; -import org.hisp.dhis.indicator.IndicatorType; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id: IndicatorTypeBatchHandlerTest.java 4949 2008-04-21 07:59:54Z larshelg $ - */ -public class IndicatorTypeBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private IndicatorService indicatorService; - - private BatchHandler batchHandler; - - private IndicatorType indicatorTypeA; - private IndicatorType indicatorTypeB; - private IndicatorType indicatorTypeC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( IndicatorTypeBatchHandler.class ); - - indicatorTypeA = createIndicatorType( 'A' ); - indicatorTypeB = createIndicatorType( 'B' ); - indicatorTypeC = createIndicatorType( 'C' ); - - batchHandler.init(); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( indicatorTypeA ); - batchHandler.addObject( indicatorTypeB ); - batchHandler.addObject( indicatorTypeC ); - - batchHandler.flush(); - - Collection indicatorTypes = indicatorService.getAllIndicatorTypes(); - - assertTrue( indicatorTypes.contains( indicatorTypeA ) ); - assertTrue( indicatorTypes.contains( indicatorTypeB ) ); - assertTrue( indicatorTypes.contains( indicatorTypeC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( indicatorTypeA, true ); - int idB = batchHandler.insertObject( indicatorTypeB, true ); - int idC = batchHandler.insertObject( indicatorTypeC, true ); - - assertNotNull( indicatorService.getIndicatorType( idA ) ); - assertNotNull( indicatorService.getIndicatorType( idB ) ); - assertNotNull( indicatorService.getIndicatorType( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( indicatorTypeA, true ); - - indicatorTypeA.setId( id ); - indicatorTypeA.setName( "UpdatedName" ); - - batchHandler.updateObject( indicatorTypeA ); - - assertEquals( "UpdatedName", indicatorService.getIndicatorType( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = indicatorService.addIndicatorType( indicatorTypeA ); - - int retrievedId = batchHandler.getObjectIdentifier( "IndicatorTypeA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - indicatorService.addIndicatorType( indicatorTypeA ); - - assertTrue( batchHandler.objectExists( indicatorTypeA ) ); - - assertFalse( batchHandler.objectExists( indicatorTypeB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/OrganisationUnitGroupBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/OrganisationUnitGroupBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/OrganisationUnitGroupBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,156 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Collection; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.organisationunit.OrganisationUnitGroup; -import org.hisp.dhis.organisationunit.OrganisationUnitGroupService; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id: OrganisationUnitGroupBatchHandlerTest.java 4949 2008-04-21 07:59:54Z larshelg $ - */ -public class OrganisationUnitGroupBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - @Autowired - private OrganisationUnitGroupService organisationUnitGroupService; - - private BatchHandler batchHandler; - - private OrganisationUnitGroup groupA; - private OrganisationUnitGroup groupB; - private OrganisationUnitGroup groupC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - batchHandler = batchHandlerFactory.createBatchHandler( OrganisationUnitGroupBatchHandler.class ); - - batchHandler.init(); - - groupA = createOrganisationUnitGroup( 'A' ); - groupB = createOrganisationUnitGroup( 'B' ); - groupC = createOrganisationUnitGroup( 'C' ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( groupA ); - batchHandler.addObject( groupB ); - batchHandler.addObject( groupC ); - - batchHandler.flush(); - - Collection groups = organisationUnitGroupService.getAllOrganisationUnitGroups(); - - assertTrue( groups.contains( groupA ) ); - assertTrue( groups.contains( groupB ) ); - assertTrue( groups.contains( groupC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( groupA, true ); - int idB = batchHandler.insertObject( groupB, true ); - int idC = batchHandler.insertObject( groupC, true ); - - assertNotNull( organisationUnitGroupService.getOrganisationUnitGroup( idA ) ); - assertNotNull( organisationUnitGroupService.getOrganisationUnitGroup( idB ) ); - assertNotNull( organisationUnitGroupService.getOrganisationUnitGroup( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( groupA, true ); - - groupA.setId( id ); - groupA.setName( "UpdatedName" ); - - batchHandler.updateObject( groupA ); - - assertEquals( "UpdatedName", organisationUnitGroupService.getOrganisationUnitGroup( id ).getName() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = organisationUnitGroupService.addOrganisationUnitGroup( groupA ); - - int retrievedId = batchHandler.getObjectIdentifier( "OrganisationUnitGroupA" ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - organisationUnitGroupService.addOrganisationUnitGroup( groupA ); - - assertTrue( batchHandler.objectExists( groupA ) ); - - assertFalse( batchHandler.objectExists( groupB ) ); - } -} === removed file 'dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/PeriodBatchHandlerTest.java' --- dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/PeriodBatchHandlerTest.java 2014-10-07 13:46:29 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/test/java/org/hisp/dhis/jdbc/batchhandler/PeriodBatchHandlerTest.java 1970-01-01 00:00:00 +0000 @@ -1,189 +0,0 @@ -package org.hisp.dhis.jdbc.batchhandler; - -/* - * Copyright (c) 2004-2014, University of Oslo - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * Neither the name of the HISP project nor the names of its contributors may - * be used to endorse or promote products derived from this software without - * specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; - -import org.amplecode.quick.BatchHandler; -import org.amplecode.quick.BatchHandlerFactory; -import org.hisp.dhis.DhisTest; -import org.hisp.dhis.period.MonthlyPeriodType; -import org.hisp.dhis.period.Period; -import org.hisp.dhis.period.PeriodService; -import org.hisp.dhis.period.PeriodType; -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -/** - * @author Lars Helge Overland - * @version $Id: PeriodBatchHandlerTest.java 4949 2008-04-21 07:59:54Z larshelg $ - */ -public class PeriodBatchHandlerTest - extends DhisTest -{ - @Autowired - private BatchHandlerFactory batchHandlerFactory; - - @Autowired - private PeriodService periodService; - - private BatchHandler batchHandler; - - private PeriodType periodType; - - private Date dateA; - private Date dateB; - private Date dateC; - private Date dateD; - - private Period periodA; - private Period periodB; - private Period periodC; - - // ------------------------------------------------------------------------- - // Fixture - // ------------------------------------------------------------------------- - - @Override - public void setUpTest() - { - periodType = periodService.getPeriodTypeByName( MonthlyPeriodType.NAME ); - - Calendar calendar = Calendar.getInstance(); - - calendar.clear(); - - calendar.set( 2000, 0, 1 ); - - dateA = calendar.getTime(); - - calendar.set( 2000, 1, 1 ); - - dateB = calendar.getTime(); - - calendar.set( 2000, 2, 1 ); - - dateC = calendar.getTime(); - - calendar.set( 2000, 3, 1 ); - - dateD = calendar.getTime(); - - batchHandler = batchHandlerFactory.createBatchHandler( PeriodBatchHandler.class ); - - batchHandler.init(); - - periodA = createPeriod( periodType, dateA, dateB ); - periodB = createPeriod( periodType, dateB, dateC ); - periodC = createPeriod( periodType, dateC, dateD ); - } - - @Override - public void tearDownTest() - { - batchHandler.flush(); - } - - @Override - public boolean emptyDatabaseAfterTest() - { - return true; - } - - // ------------------------------------------------------------------------- - // Tests - // ------------------------------------------------------------------------- - - @Test - public void testAddObject() - { - batchHandler.addObject( periodA ); - batchHandler.addObject( periodB ); - batchHandler.addObject( periodC ); - - batchHandler.flush(); - - Collection periods = periodService.getPeriodsByPeriodType( periodType ); - - assertTrue( periods.contains( periodA ) ); - assertTrue( periods.contains( periodB ) ); - assertTrue( periods.contains( periodC ) ); - } - - @Test - public void testInsertObject() - { - int idA = batchHandler.insertObject( periodA, true ); - int idB = batchHandler.insertObject( periodB, true ); - int idC = batchHandler.insertObject( periodC, true ); - - assertNotNull( periodService.getPeriod( idA ) ); - assertNotNull( periodService.getPeriod( idB ) ); - assertNotNull( periodService.getPeriod( idC ) ); - } - - @Test - public void testUpdateObject() - { - int id = batchHandler.insertObject( periodA, true ); - - periodA.setStartDate( dateA ); - - batchHandler.updateObject( periodA ); - - assertEquals( dateA, periodService.getPeriod( id ).getStartDate() ); - } - - @Test - public void testGetObjectIdentifier() - { - int referenceId = periodService.addPeriod( periodA ); - - int retrievedId = batchHandler.getObjectIdentifier( periodA ); - - assertEquals( referenceId, retrievedId ); - } - - @Test - public void testObjectExists() - { - periodService.addPeriod( periodA ); - - assertTrue( batchHandler.objectExists( periodA ) ); - - assertFalse( batchHandler.objectExists( periodB ) ); - } -}