Improve test coverage in TcaRequestFormatter 82/85682/2
authorm.kowalski3 <m.kowalski3@partner.samsung.com>
Thu, 18 Apr 2019 11:45:08 +0000 (13:45 +0200)
committerm.kowalski3 <m.kowalski3@partner.samsung.com>
Thu, 18 Apr 2019 13:45:49 +0000 (15:45 +0200)
Issue-ID: CLAMP-349
Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com>
Change-Id: I617261a1a71f0a0007286be9cf09024c71419c68

src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java

index 095df9d..c92cdcf 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2019 Nokia Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -31,7 +33,9 @@ import static org.mockito.Mockito.when;
 import com.google.gson.JsonObject;
 import java.io.IOException;
 import org.junit.Test;
+import org.mockito.Mockito;
 import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.clds.exception.TcaRequestFormatterException;
 import org.onap.clamp.clds.model.properties.ModelProperties;
 import org.onap.clamp.clds.model.properties.Tca;
 import org.onap.clamp.clds.model.properties.TcaItem;
@@ -95,4 +99,18 @@ public class TcaRequestFormatterTest {
         //then
         assertThat(expectedRequest).isEqualTo(policyContent);
     }
+
+    @Test(expected = TcaRequestFormatterException.class)
+    public void shouldThrowTcaRequestFormatterException() throws IOException{
+        //given
+        String service = "TestService";
+        String policy = "TestService_scope.PolicyName";
+        ClampProperties clampProperties =  mock(ClampProperties.class);
+        ModelProperties modelProperties = mock(ModelProperties.class);
+        Tca tca = mock(Tca.class);
+        //when
+        Mockito.when(clampProperties.getJsonTemplate(any(), any())).thenThrow(IOException.class);
+        //then
+        TcaRequestFormatter.createPolicyContent(clampProperties, modelProperties, service, policy, tca);
+    }
 }
\ No newline at end of file