OnapPdpEngineFactory extends PDPEngineFactory { @Override public PDPEngine newEngine() throws FactoryException { final EvaluationContextFactory evaluationContextFactory = EvaluationContextFactory.newInstance(); if (evaluationContextFactory == null) { this.logger.error("Null EvaluationContextFactory"); throw new FactoryException("Null EvaluationContextFactory"); } return new OnapPdpEngine(evaluationContextFactory, this.getDefaultBehavior(), this.getScopeResolver()); }  @Override PDPEngine newEngine(); @Override PDPEngine newEngine(final Properties properties);  }
@Test public final void testNewEngine() { final OnapPdpEngineFactory pdpEngine = new OnapPdpEngineFactory(); try { assertTrue(pdpEngine.newEngine() != null); } catch (final Exception e) { fail("operation failed, e=" + e); } }
@Test public final void testNewEngineProperties() { final OnapPdpEngineFactory pdpEngine = new OnapPdpEngineFactory(); final Properties properties = new Properties(); try { assertTrue(pdpEngine.newEngine(properties) != null); } catch (final Exception e) { fail("operation failed, e=" + e); } }
@PrepareForTest({ EvaluationContextFactory.class, FactoryFinder.class }) @Test(expected = FactoryException.class) public void testNegTestEngine() throws FactoryException { PowerMockito.mockStatic(FactoryFinder.class); PowerMockito.when(FactoryFinder.find(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(null); final OnapPdpEngineFactory factory = new OnapPdpEngineFactory(); factory.newEngine(); fail("Expecting an exception."); }
@PrepareForTest({ EvaluationContextFactory.class, FactoryFinder.class }) @Test(expected = FactoryException.class) public void testNegTestEngine2() throws FactoryException { PowerMockito.mockStatic(FactoryFinder.class); PowerMockito.when(FactoryFinder.find(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(null); final OnapPdpEngineFactory factory = new OnapPdpEngineFactory(); final Properties properties = new Properties(); factory.newEngine(properties); fail("Expecting an exception."); }