import java.net.URI;\r
import java.net.URISyntaxException;\r
import java.net.URL;\r
+\r
+import org.junit.Rule;\r
import org.junit.Test;\r
+import org.junit.rules.ExpectedException;\r
import org.onap.holmes.common.dcae.entity.DcaeConfigurations;\r
import org.onap.holmes.common.dcae.entity.SecurityInfo;\r
+import org.onap.holmes.common.exception.CorrelationException;\r
\r
public class DcaeConfigurationParserTest {\r
\r
+ @Rule\r
+ public ExpectedException thrown = ExpectedException.none();\r
+\r
@Test\r
public void parse() throws Exception {\r
DcaeConfigurations obj = DcaeConfigurationParser.parse(readConfigurationsFromFile("dcae.config.json"));\r
assertThat(((SecurityInfo) obj.getPubSecInfo("sec_measurement")).getDmaapInfo().getLocation(), equalTo("mtl5"));\r
}\r
\r
+ @Test\r
+ public void parse_with_empty_contents_excption() throws CorrelationException {\r
+ thrown.expect(CorrelationException.class);\r
+ thrown.expectMessage("Can not resolve configurations from DCAE. The configuration string is empty.");\r
+ DcaeConfigurationParser.parse("");\r
+ }\r
+\r
+ @Test\r
+ public void parse_with_illegal_dcae_response_excption() throws CorrelationException {\r
+ thrown.expect(CorrelationException.class);\r
+ DcaeConfigurationParser.parse("This is an ordinary string.");\r
+ }\r
+\r
private String readConfigurationsFromFile(String fileName) throws URISyntaxException, FileNotFoundException {\r
URL url = DcaeConfigurationParserTest.class.getClassLoader().getResource(fileName);\r
File configFile = new File(new URI(url.toString()).getPath());\r