@Test(expected = MongoException.class) public void createConnectionException2Test() { try { when(mongo.getDB(anyString())).thenThrow(MongoException.class); } catch (Exception ex) { fail(ex.getLocalizedMessage()); } MongoDAOFactory.createConnection(); }
@Test public void getResourceDAOTest() { mongoResourceDAO = mock(MongoResourceDAO.class); try { PowerMockito.whenNew(MongoResourceDAO.class).withNoArguments().thenReturn(mongoResourceDAO); } catch (Exception ex) { fail(ex.getLocalizedMessage()); } toTest = new MongoDAOFactory(); toTest.getResourceDAO(); }
@Test public void createConnection3Test() { MongoDAOFactory.createConnection(); verify(mongo).getDB(anyString()); }