X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fcomponents%2FBRMSPolicyTest.java;h=333d878ca9f5ecc0277653b46e3bc4d038a1ba49;hp=c13d1f1fe68777701af93959e03a370f90bf0a5f;hb=1e61676b77dd09659027b8984f050df7e8538526;hpb=45980fe83716dd804d9b1ce115088d096454f6d3 diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java index c13d1f1fe..333d878ca 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/components/BRMSPolicyTest.java @@ -2,14 +2,16 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T 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 - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,38 +19,53 @@ * limitations under the License. * ============LICENSE_END========================================================= */ + package org.onap.policy.pap.xacml.rest.components; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; + import java.io.IOException; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.mockito.Mockito; import org.onap.policy.rest.dao.CommonClassDao; public class BRMSPolicyTest { - @Rule + @Rule public ExpectedException thrown = ExpectedException.none(); - @Test - public void testConstructor1() { - CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate(); - assertNotNull(template); - } - - @Test - public void testConstructor2() { - CommonClassDao commonClassDao = null; - CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate(commonClassDao); - assertNotNull(template); - } - - @Test - public void testReadFile() throws IOException { - String goodRule = "declare Params\nparam1 : int\nend\n"; - String badRule = "declare Params\nparam1+ : int\nend\n"; - assertEquals(CreateBRMSRuleTemplate.validateRuleParams(goodRule), true); - assertEquals(CreateBRMSRuleTemplate.validateRuleParams(badRule), false); - } -} \ No newline at end of file + @Test + public void testConstructor1() { + CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate(); + assertNotNull(template); + } + + @Test + public void testConstructor2() { + CommonClassDao commonClassDao = null; + CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate(commonClassDao); + assertNotNull(template); + } + + @Test + public void testReadFile() throws IOException { + String goodRule = "declare Params\nparam1 : int\nend\n"; + String badRule = "declare Params\nparam1+ : int\nend\n"; + assertEquals(CreateBRMSRuleTemplate.validateRuleParams(goodRule), true); + assertEquals(CreateBRMSRuleTemplate.validateRuleParams(badRule), false); + } + + @Test + public void testAdd() { + CommonClassDao dao = Mockito.mock(CommonClassDao.class); + CreateBRMSRuleTemplate template = new CreateBRMSRuleTemplate(dao); + String rule = "package foo\n"; + String ruleName = "testName"; + String description = "testDesc"; + String userID = "testID"; + assertEquals(1, template.addRule(rule, ruleName, description, userID).size()); + } +}