import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
+
import com.mockrunner.mock.web.MockHttpServletRequest;
import com.mockrunner.mock.web.MockHttpServletResponse;
+
import java.util.Collections;
import java.util.List;
+
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
-import org.onap.policy.common.logging.ONAPLoggingContext;
+import org.onap.policy.common.logging.OnapLoggingContext;
import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
import org.onap.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
import org.onap.policy.pap.xacml.rest.elk.client.PolicyElasticSearchController;
PolicyElasticSearchController controller = Mockito.mock(PolicyElasticSearchController.class);
PowerMockito.whenNew(PolicyElasticSearchController.class).withNoArguments().thenReturn(controller);
- // Test deletion from PAP
- MockHttpServletResponse response = new MockHttpServletResponse();
- try {
- handler.doApiDeleteFromPap(request, response);
- } catch (Exception ex) {
- fail("Not expecting an exception: " + ex);
- }
+ // Test deletion from PAP
+ MockHttpServletResponse response = new MockHttpServletResponse();
+ try {
+ handler.doApiDeleteFromPap(request, response);
+ } catch (Exception ex) {
+ fail("Not expecting an exception: " + ex);
+ }
// Test deletion from PDP
- ONAPLoggingContext loggingContext = Mockito.mock(ONAPLoggingContext.class);
+ OnapLoggingContext loggingContext = Mockito.mock(OnapLoggingContext.class);
try {
handler.doApiDeleteFromPdp(request, response, loggingContext);
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
fail("Not expecting an exception: " + ex);
}
- // Test delete entity
- PolicyEntity policyEntity = new PolicyEntity();
- policyEntity.setPolicyName("testVal");
- String result = DeleteHandler.deletePolicyEntityData(policyEntity);
- assertEquals(result, "success");
+ // Test delete entity
+ PolicyEntity policyEntity = new PolicyEntity();
+ policyEntity.setPolicyName("testVal");
+ String result = DeleteHandler.deletePolicyEntityData(policyEntity);
+ assertEquals(result, "success");
- // Test check entity
- List<?> peResult = Collections.emptyList();
- assertEquals(DeleteHandler.checkPolicyGroupEntity(peResult), false);
- }
+ // Test check entity
+ List<?> peResult = Collections.emptyList();
+ assertEquals(DeleteHandler.checkPolicyGroupEntity(peResult), false);
+ }
}