JSONDDMStorageAdapter implements DDMStorageAdapter { protected DDMStorageAdapterSaveResponse insert( DDMStorageAdapterSaveRequest ddmStorageAdapterSaveRequest) throws StorageException { DDMFormValues ddmFormValues = ddmStorageAdapterSaveRequest.getDDMFormValues(); try { ServiceContext serviceContext = new ServiceContext(); serviceContext.setScopeGroupId( ddmStorageAdapterSaveRequest.getScopeGroupId()); serviceContext.setUserId(ddmStorageAdapterSaveRequest.getUserId()); serviceContext.setUuid(ddmStorageAdapterSaveRequest.getUuid()); DDMContent ddmContent = ddmContentLocalService.addContent( ddmStorageAdapterSaveRequest.getUserId(), ddmStorageAdapterSaveRequest.getScopeGroupId(), ddmStorageAdapterSaveRequest.getClassName(), null, serialize(ddmFormValues), serviceContext); DDMStorageAdapterSaveResponse.Builder builder = DDMStorageAdapterSaveResponse.Builder.newBuilder( ddmContent.getPrimaryKey()); 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 testInsert() throws Exception { DDMContent ddmContent = mock(DDMContent.class); when( _ddmContentLocalService.addContent( Matchers.anyLong(), Matchers.anyLong(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.any(ServiceContext.class)) ).thenReturn( ddmContent ); when( ddmContent.getPrimaryKey() ).thenReturn( 1L ); DDMFormValues ddmFormValues = mock(DDMFormValues.class); DDMFormValuesSerializerSerializeResponse ddmFormValuesSerializerSerializeResponse = DDMFormValuesSerializerSerializeResponse.Builder.newBuilder( "{}" ).build(); when( _ddmFormValuesSerializer.serialize( Mockito.any(DDMFormValuesSerializerSerializeRequest.class)) ).thenReturn( ddmFormValuesSerializerSerializeResponse ); DDMStorageAdapterSaveRequest.Builder builder = DDMStorageAdapterSaveRequest.Builder.newBuilder( 1, 1, ddmFormValues); DDMStorageAdapterSaveRequest ddmStorageAdapterSaveRequest = builder.build(); DDMStorageAdapterSaveResponse ddmStorageAdapterSaveResponse = _jsonDDMStorageAdapter.save(ddmStorageAdapterSaveRequest); Assert.assertEquals(1L, ddmStorageAdapterSaveResponse.getPrimaryKey()); Mockito.verify( _ddmFormValuesSerializer, Mockito.times(1) ).serialize( Mockito.any(DDMFormValuesSerializerSerializeRequest.class) ); Mockito.verify( _ddmContentLocalService, Mockito.times(1) ).addContent( Matchers.anyLong(), Matchers.anyLong(), Matchers.anyString(), Matchers.anyString(), Matchers.anyString(), Matchers.any(ServiceContext.class) ); }