X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=BRMSGateway%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Fpolicy%2Fbrms%2Fapi%2FBrmsHandlerTest.java;h=079db2109f3f8070e4c1473929521dda91548d83;hb=e37f5a70bcf3fd8073418c13416cc79c0ef47d59;hp=58bacef131316741ce20986114b608014f5f564b;hpb=d4b467daed74656582045f4561e6c7745cf7bf6f;p=policy%2Fengine.git diff --git a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java index 58bacef13..079db2109 100644 --- a/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java +++ b/BRMSGateway/src/test/java/org/onap/policy/brms/api/BrmsHandlerTest.java @@ -2,14 +2,14 @@ * ============LICENSE_START======================================================= * ONAP Policy Engine * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018, 2020 AT&T Intellectual Property. All rights reserved. * ================================================================================ * 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. @@ -23,13 +23,13 @@ package org.onap.policy.brms.api; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; +import static org.mockito.ArgumentMatchers.any; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.Persistence; -import javax.persistence.Query; +import javax.persistence.TypedQuery; import org.junit.Test; import org.junit.runner.RunWith; @@ -38,14 +38,16 @@ import org.onap.policy.api.NotificationType; import org.onap.policy.std.StdPDPNotification; import org.onap.policy.utils.BackUpMonitor; import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) +@PowerMockIgnore({"com.sun.org.apache.xerces.*", "jdk.internal.reflect.*", "javax.xml.*", "org.xml.*", "org.w3c.*"}) +@PrepareForTest({Persistence.class, BackUpMonitor.class}) public class BrmsHandlerTest { - @PrepareForTest({Persistence.class, BackUpMonitor.class}) @Test - public void negativeTestNotifications() throws Exception { + public void testNegativeTestNotifications() throws Exception { // Mock emf, persistence, and query final EntityManagerFactory emf = Mockito.mock(EntityManagerFactory.class); final EntityManager em = Mockito.mock(EntityManager.class); @@ -54,8 +56,8 @@ public class BrmsHandlerTest { PowerMockito.when(Persistence.createEntityManagerFactory(any(), any())).thenReturn(emf); final EntityTransaction et = Mockito.mock(EntityTransaction.class); Mockito.when(em.getTransaction()).thenReturn(et); - final Query query = Mockito.mock(Query.class); - Mockito.when(em.createQuery(Mockito.anyString())).thenReturn(query); + final TypedQuery query = Mockito.mock(TypedQuery.class); + Mockito.when(em.createQuery(Mockito.anyString(), Mockito.any())).thenReturn((TypedQuery) query); // Mock backup monitor PowerMockito.mockStatic(BackUpMonitor.class);