added some more test cases ValidatorUtilTest.java 11/68911/1
authorasgar <sammoham@in.ibm.com>
Tue, 25 Sep 2018 16:06:19 +0000 (21:36 +0530)
committerasgar <sammoham@in.ibm.com>
Tue, 25 Sep 2018 16:06:27 +0000 (21:36 +0530)
Change-Id: Ia7a240aad73eff0c6d9944f845125677e6e5611b
Issue-ID: DMAAP-809
Signed-off-by: Mohamed Asgar Samiulla <sammoham@in.ibm.com>
src/test/java/com/att/nsa/mr/tools/ValidatorUtilTest.java

index baec4d8..9317375 100644 (file)
@@ -89,4 +89,83 @@ public class ValidatorUtilTest {
         }
         
     }
+    
+    
+    
+    
+    @Test
+    public void testValidateForNonDME2WithNullServiceName() {
+        Properties props = new Properties();
+        props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+        try{
+            ValidatorUtil.validatePublisher(props);
+        } catch(IllegalArgumentException e) {
+            assertEquals(e.getMessage(), "Servicename is needed");
+        }
+        
+    }
+    
+    @Test
+    public void testValidateForNonDME2WithNullTopic() {
+        Properties props = new Properties();
+        props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+        props.setProperty("host", "ServiceName");
+        try{
+            ValidatorUtil.validatePublisher(props);
+        } catch(IllegalArgumentException e) {
+            assertEquals(e.getMessage(), "topic is needed");
+        }
+        
+    }
+    
+    @Test
+    public void testValidateForNonDME2WithNullContenttype() {
+        Properties props = new Properties();
+        props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+        props.setProperty("host", "ServiceName");
+        props.setProperty("topic", "topic");
+        try{
+            ValidatorUtil.validatePublisher(props);
+        } catch(IllegalArgumentException e) {
+            assertEquals(e.getMessage(), "contenttype is needed");
+        }
+        
+    }
+
+    
+    @Test
+    public void testValidateForNonDME2WithNullUserName() {
+        Properties props = new Properties();
+        props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+        props.setProperty("host", "ServiceName");
+        props.setProperty("topic", "topic");
+        props.setProperty("contenttype", "contenttype");
+        try{
+            ValidatorUtil.validatePublisher(props);
+        } catch(IllegalArgumentException e) {
+            assertEquals(e.getMessage(), "username is needed");
+        }
+        
+    }
+    
+    @Test
+    public void testValidateForNonDME2WithNullPassword() {
+        Properties props = new Properties();
+        props.setProperty("TransportType", ProtocolTypeConstants.AUTH_KEY.getValue());
+        props.setProperty("host", "ServiceName");
+        props.setProperty("topic", "topic");
+        props.setProperty("username", "username");
+        props.setProperty("contenttype", "contenttype");
+        
+        try{
+            ValidatorUtil.validatePublisher(props);
+        } catch(IllegalArgumentException e) {
+            assertEquals(e.getMessage(), "password is needed");
+        }
+        
+    }
+    
+    
+    
+    
 }