|
| 1 | +/** |
| 2 | + * This Source Code Form is subject to the terms of the Mozilla Public License, |
| 3 | + * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 4 | + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under |
| 5 | + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. |
| 6 | + * |
| 7 | + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS |
| 8 | + * graphic logo is a trademark of OpenMRS Inc. |
| 9 | + */ |
| 10 | +package org.openmrs.module.initializer.api.queues; |
| 11 | + |
| 12 | +import org.junit.Assert; |
| 13 | +import org.junit.Before; |
| 14 | +import org.junit.Test; |
| 15 | +import org.openmrs.module.initializer.DomainBaseModuleContextSensitive_2_3_Test; |
| 16 | +import org.openmrs.module.queue.api.QueueService; |
| 17 | +import org.openmrs.module.queue.model.Queue; |
| 18 | +import org.springframework.beans.factory.annotation.Autowired; |
| 19 | +import org.springframework.beans.factory.annotation.Qualifier; |
| 20 | + |
| 21 | +public class QueueLoaderIntegrationTest extends DomainBaseModuleContextSensitive_2_3_Test { |
| 22 | + |
| 23 | + @Autowired |
| 24 | + @Qualifier("queue.QueueService") |
| 25 | + private QueueService queueService; |
| 26 | + |
| 27 | + @Autowired |
| 28 | + private QueueLoader loader; |
| 29 | + |
| 30 | + @Before |
| 31 | + public void setup() throws Exception { |
| 32 | + executeDataSet("testdata/test-queues.xml"); |
| 33 | + } |
| 34 | + |
| 35 | + @Test |
| 36 | + public void load_shouldLoadAccordingToCsvFiles() throws Exception { |
| 37 | + |
| 38 | + // Initial Queue |
| 39 | + { |
| 40 | + Queue queue = queueService.getQueueByUuid("2a0e0eee-6888-11ee-ab8d-0242ac120002").orElse(null); |
| 41 | + Assert.assertNotNull(queue); |
| 42 | + Assert.assertEquals("Initial Queue", queue.getName()); |
| 43 | + Assert.assertEquals("", queue.getDescription()); |
| 44 | + Assert.assertEquals(2001, queue.getService().getConceptId().intValue()); |
| 45 | + Assert.assertEquals(1, queue.getLocation().getLocationId().intValue()); |
| 46 | + } |
| 47 | + |
| 48 | + loader.load(); |
| 49 | + |
| 50 | + // Revised Queue |
| 51 | + { |
| 52 | + Queue queue = queueService.getQueueByUuid("2a0e0eee-6888-11ee-ab8d-0242ac120002").orElse(null); |
| 53 | + Assert.assertNotNull(queue); |
| 54 | + Assert.assertEquals("Revised Queue", queue.getName()); |
| 55 | + Assert.assertEquals("Revised Description", queue.getDescription()); |
| 56 | + Assert.assertEquals(2002, queue.getService().getConceptId().intValue()); |
| 57 | + Assert.assertEquals(2, queue.getLocation().getLocationId().intValue()); |
| 58 | + } |
| 59 | + // New Queue |
| 60 | + { |
| 61 | + Queue queue = queueService.getQueueByUuid("288db1cc-688a-11ee-ab8d-0242ac120002").orElse(null); |
| 62 | + Assert.assertNotNull(queue); |
| 63 | + Assert.assertEquals("New Queue", queue.getName()); |
| 64 | + Assert.assertEquals("New Description", queue.getDescription()); |
| 65 | + Assert.assertEquals(2001, queue.getService().getConceptId().intValue()); |
| 66 | + Assert.assertEquals(3, queue.getLocation().getLocationId().intValue()); |
| 67 | + } |
| 68 | + } |
| 69 | +} |
0 commit comments