PostMethodHandler extends WriteMethodHandler { @Override public ProcessorResult handleWrite(Object entity) throws ODataException { if (entity instanceof ODataLink) { return processLink((ODataLink) entity); } else { if (entity == null) { throw new ODataBadRequestException("The body of a POST request must contain a valid entity."); } return processEntity(entity); } } PostMethodHandler(ODataRequestContext requestContext, DataSourceFactory dataSourceFactory); @Override ProcessorResult handleWrite(Object entity);  }
@Test(expected = ODataBadRequestException.class) public void testWriteWithNull() throws Exception { EntityDataModel entityDataModel = getEntityDataModel(); stubForTesting(getEntity(), entityDataModel); getPostMethodHandler(entityDataModel, true).handleWrite(null); }
@Test(expected = ODataBadRequestException.class) public void testWriteNonEntitySet() throws Exception { stubForTesting(getEntity(), getEntityDataModel()); WriteMethodHandler writeMethodHandler = getPostMethodHandler(getEntityDataModel(), false); writeMethodHandler.handleWrite(getEntity()); }