← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12942: Fix patient service test, create sample SmsConfiguration

 

------------------------------------------------------------
revno: 12942
committer: Long <Long@Long-Laptop>
branch nick: dhis2
timestamp: Thu 2013-11-14 16:51:24 +0700
message:
  Fix patient service test, create sample SmsConfiguration
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java
  dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java	2013-09-05 06:05:43 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/sms/SmsMessageSender.java	2013-11-14 09:51:24 +0000
@@ -88,7 +88,7 @@
     {
         String message = null;
 
-        if ( outboundSmsTransportService == null || outboundSmsTransportService.getGatewayMap() == null )
+        if ( outboundSmsTransportService == null || outboundSmsTransportService.getGatewayMap() == null || !outboundSmsTransportService.isEnabled() )
         {
             message = "No gateway";
             return message;

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java'
--- dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java	2013-11-14 08:17:57 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/test/java/org/hisp/dhis/program/ProgramInstanceServiceTest.java	2013-11-14 09:51:24 +0000
@@ -46,6 +46,9 @@
 import org.hisp.dhis.patient.PatientReminder;
 import org.hisp.dhis.patient.PatientService;
 import org.hisp.dhis.period.PeriodType;
+import org.hisp.dhis.sms.config.BulkSmsGatewayConfig;
+import org.hisp.dhis.sms.config.SmsConfiguration;
+import org.hisp.dhis.sms.config.SmsConfigurationManager;
 import org.hisp.dhis.sms.outbound.OutboundSms;
 import org.junit.Test;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -73,6 +76,9 @@
 
     @Autowired
     private ProgramStageService programStageService;
+    
+    @Autowired
+    private SmsConfigurationManager smsConfigurationManager; 
 
     private Date incidenDate;
 
@@ -557,6 +563,10 @@
     @Test
     public void testSendMessageConversations()
     {
+        this.createSMSConfiguration();
+        SmsConfiguration smsConfiguration = new SmsConfiguration();
+        smsConfiguration.setEnabled( true );
+        
         programInstanceService.addProgramInstance( programInstanceB );
 
         Collection<OutboundSms> outboundSmsList = programInstanceService.sendMessages( programInstanceA,
@@ -609,4 +619,20 @@
         assertEquals( ProgramInstance.STATUS_CANCELLED, programInstanceService.getProgramInstance( idA ).getStatus() );
         assertEquals( ProgramInstance.STATUS_CANCELLED, programInstanceService.getProgramInstance( idD ).getStatus() );
     }
+    
+    private void createSMSConfiguration() {
+        BulkSmsGatewayConfig bulkGatewayConfig = new BulkSmsGatewayConfig();
+        bulkGatewayConfig.setName( "bulksms" );
+        bulkGatewayConfig.setPassword( "bulk" );
+        bulkGatewayConfig.setUsername( "bulk" );
+        bulkGatewayConfig.setRegion( "uk" );
+        bulkGatewayConfig.setDefault( true );
+        
+        SmsConfiguration smsConfig = new SmsConfiguration();
+        smsConfig.setPollingInterval( 3000 );
+        smsConfig.getGateways().add( bulkGatewayConfig );
+        smsConfig.setEnabled( true );
+        smsConfigurationManager.updateSmsConfiguration( smsConfig );
+        
+    }
 }