How to pass this test case? Please public void testDao(){ MessageDao.reset(); MessageDao messageDao = MessageDao.getInstance(); Assert.assertEquals(messageDao, MessageDao.getInstance()); // test that constructor is private List constructors = Arrays.asList(MessageDao.class.getConstructors()); Assert.assertEquals(constructors.size(), 0); constructors = Arrays.asList(MessageDao.class.getDeclaredConstructors()); Assert.assertEquals(constructors.size(), 1); Assert.assertTrue(Modifier.isPrivate(constructors.get(0).getModifiers())); } We are supposed to fill this out in order to pass this test: package dao; import dto.MessageDto; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; // TODO fill this out public class MessageDao implements BaseDao { private static MessageDao instance = new MessageDao(); public static MessageDao getInstance() { } // TODO fill this out @Override public void put(MessageDto messageDto) { } // TODO fill this out @Override public MessageDto get(String uniqueId) { return null; } // TODO fill this out @Override public List getAll() { return null; } // only for testing, do not call this method public static void reset(){ instance = new MessageDao(); } } We are supposed to fill out the TODO sections. No hand written and fast answer with explanation
How to pass this test case? Please
public void testDao(){ MessageDao.reset(); MessageDao messageDao = MessageDao.getInstance(); Assert.assertEquals(messageDao, MessageDao.getInstance()); // test that constructor is private List<Constructor> constructors = Arrays.asList(MessageDao.class.getConstructors()); Assert.assertEquals(constructors.size(), 0); constructors = Arrays.asList(MessageDao.class.getDeclaredConstructors()); Assert.assertEquals(constructors.size(), 1); Assert.assertTrue(Modifier.isPrivate(constructors.get(0).getModifiers())); }
We are supposed to fill this out in order to pass this test:
package dao; import dto.MessageDto; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; // TODO fill this out public class MessageDao implements BaseDao<MessageDto> { private static MessageDao instance = new MessageDao(); public static MessageDao getInstance() { } // TODO fill this out @Override public void put(MessageDto messageDto) { } // TODO fill this out @Override public MessageDto get(String uniqueId) { return null; } // TODO fill this out @Override public List<MessageDto> getAll() { return null; } // only for testing, do not call this method public static void reset(){ instance = new MessageDao(); } }
We are supposed to fill out the TODO sections.
No hand written and fast answer with explanation
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images