JSONDDMStorageAdapter implements DDMStorageAdapter { @Override public DDMStorageAdapterGetResponse get( DDMStorageAdapterGetRequest ddmStorageAdapterGetRequest) throws StorageException { try { DDMContent ddmContent = ddmContentLocalService.getContent( ddmStorageAdapterGetRequest.getPrimaryKey()); DDMFormValues ddmFormValues = deserialize( ddmContent.getData(), ddmStorageAdapterGetRequest.getDDMForm()); DDMStorageAdapterGetResponse.Builder builder = DDMStorageAdapterGetResponse.Builder.newBuilder(ddmFormValues); return builder.build(); } catch (Exception exception) { throw new StorageException(exception); } }  @Override DDMStorageAdapterDeleteResponse delete(
			DDMStorageAdapterDeleteRequest ddmStorageAdapterDeleteRequest); @Override DDMStorageAdapterGetResponse get(
			DDMStorageAdapterGetRequest ddmStorageAdapterGetRequest); @Override DDMStorageAdapterSaveResponse save(
			DDMStorageAdapterSaveRequest ddmStorageAdapterSaveRequest);  }
@Test public void testGet() throws Exception { DDMContent ddmContent = mock(DDMContent.class); when( _ddmContentLocalService.getContent(1) ).thenReturn( ddmContent ); String data = "{}"; when( ddmContent.getData() ).thenReturn( data ); DDMForm ddmForm = mock(DDMForm.class); DDMFormValues ddmFormValues = mock(DDMFormValues.class); DDMFormValuesDeserializerDeserializeResponse ddmFormValuesDeserializerDeserializeResponse = DDMFormValuesDeserializerDeserializeResponse.Builder.newBuilder( ddmFormValues ).build(); when( _ddmFormValuesDeserializer.deserialize( Mockito.any(DDMFormValuesDeserializerDeserializeRequest.class)) ).thenReturn( ddmFormValuesDeserializerDeserializeResponse ); DDMStorageAdapterGetRequest.Builder builder = DDMStorageAdapterGetRequest.Builder.newBuilder(1, ddmForm); DDMStorageAdapterGetResponse ddmStorageAdapterGetResponse = _jsonDDMStorageAdapter.get(builder.build()); Assert.assertNotNull(ddmStorageAdapterGetResponse.getDDMFormValues()); Mockito.verify( _ddmContentLocalService, Mockito.times(1) ).getContent( 1 ); Mockito.verify( _ddmFormValuesDeserializer, Mockito.times(1) ).deserialize( Mockito.any(DDMFormValuesDeserializerDeserializeRequest.class) ); }
@Test(expected = StorageException.class) public void testGetException() throws Exception { when( _ddmContentLocalService.getContent(1) ).thenThrow( Exception.class ); DDMForm ddmForm = mock(DDMForm.class); DDMStorageAdapterGetRequest.Builder builder = DDMStorageAdapterGetRequest.Builder.newBuilder(1, ddmForm); _jsonDDMStorageAdapter.get(builder.build()); }