DiskObjectRepository implements ObjectRepository { public Object getObject(InputStream inputStream) throws IOException, ClassNotFoundException { return new ObjectInputStream(inputStream).readObject(); }  void saveObject(Object objectToBeSerialized, OutputStream outputStream); Object getObject(InputStream inputStream); boolean objectAlreadyExist(String objectId, String location); void saveObject(Object object, String objectId, String location); Object getObject(String objectId, String location); @Override boolean clearObjectIfAvailable(String objectId, String location);  }
@SuppressWarnings("rawtypes") @Test public void shouldReadObj() throws Exception { List recordedList = (List) objectRepository .getObject(this.getClass().getClassLoader().getResourceAsStream("com/svashishtha/mocktail/util/recorded_list.ser")); assertThat(recordedList.size(), is(4)); }
@Test public void shouldGetObject() throws Exception { String locationDirectory = getAbsolutePath("src", "test", "resources", "com", "svashishtha","mocktail", "util"); List recordedList = (List) objectRepository.getObject( "recorded_list.ser", locationDirectory); assertThat(recordedList.size(), is(4)); assertThat((String) recordedList.get(0), is("sandy")); assertThat((String) recordedList.get(1), is("ganesh")); assertThat((Integer) recordedList.get(2), is(12)); assertThat((Double) recordedList.get(3), is(23.0)); }