import com.att.research.xacml.api.Attribute;
import com.att.research.xacml.api.AttributeValue;
-import com.att.research.xacml.api.Status;
import com.att.research.xacml.api.pip.PIPException;
import com.att.research.xacml.api.pip.PIPFinder;
import com.att.research.xacml.api.pip.PIPRequest;
import com.att.research.xacml.api.pip.PIPResponse;
import com.att.research.xacml.std.pip.StdPIPResponse;
import jakarta.persistence.EntityManager;
+import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.Persistence;
import jakarta.persistence.Query;
import java.io.FileInputStream;
import java.util.Properties;
import java.util.Queue;
import java.util.UUID;
+import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
private static final String TARGET = "my-target";
private static final String TEST_PROPERTIES = "src/test/resources/test.properties";
+ private static EntityManagerFactory emf;
private static EntityManager em;
@Mock
@Mock
private PIPResponse resp3;
- @Mock
- private Status okStatus;
-
private Properties properties;
private Queue<PIPResponse> responses;
private Queue<String> attributes;
//
String persistenceUnit = CountRecentOperationsPip.ISSUER_NAME + ".persistenceunit";
LOGGER.info("persistenceunit {}", persistenceUnit);
- em = Persistence.createEntityManagerFactory(props2.getProperty(persistenceUnit), props2).createEntityManager();
+ emf = Persistence.createEntityManagerFactory(props2.getProperty(persistenceUnit), props2);
+ em = emf.createEntityManager();
//
//
//
- LOGGER.info("Configured own entity manager", em.toString());
+ LOGGER.info("Configured own entity manager {}", em.toString());
}
/**
}
@Test
- public void testConfigure_DbException() throws Exception {
+ public void testConfigure_DbException() {
properties.put("jakarta.persistence.jdbc.url", "invalid");
assertThatCode(() ->
pipEngine.configure("issuer", properties)
//
// create entry
//
- OperationsHistory newEntry = createEntry("cl-foobar-1", "vnf-1", "SUCCESS");
+ OperationsHistory newEntry = createEntry();
//
// No entries yet
//
}
@Test
- public void testStringToChronoUnit() throws PIPException {
+ public void testStringToChronosUnit() throws PIPException {
// not configured yet
- OperationsHistory newEntry = createEntry("cl-foobar-1", "vnf-1", "SUCCESS");
+ OperationsHistory newEntry = createEntry();
assertEquals(-1, getCount(newEntry));
// now configure it
return ((Number) value.getValue()).longValue();
}
- private OperationsHistory createEntry(String cl, String target, String outcome) {
+ private OperationsHistory createEntry() {
//
// Create entry
//
OperationsHistory newEntry = new OperationsHistory();
- newEntry.setClosedLoopName(cl);
- newEntry.setTarget(target);
- newEntry.setOutcome(outcome);
+ newEntry.setClosedLoopName("cl-foobar-1");
+ newEntry.setTarget("vnf-1");
+ newEntry.setOutcome("SUCCESS");
newEntry.setActor("Controller");
newEntry.setOperation("operationA");
newEntry.setStarttime(Date.from(Instant.now().minusMillis(20000)));