If a deployment contains a process definition and a corresponding diagram, than both are successful deployed.
If a process definition query is returned the returned process definition entity contains the diagram resource name.
Is the cache cleared and the method
repositoryService.getProcessDiagram(processDefinition.getId()); used, then the process definition can not resolved from the cache. This ends in redeployment of the corresponding deployment, which is identified via the ID. Problem lies in the CacheDeployer#deployOnlyGivenResourceOfDeployment, which calls the CacheDeployer#initDeployment. This init method only loads one resource for the deployment. In this case the corresponding diagram are not redeployed - so the process definition which is added into the cache contains no diagram resource name.
The result is that repositoryService.getProcessDiagram(processDefinition.getId()); and repositoryService.getProcessDiagramLayout(processDefinition.getId()); returns null!
Added failing test case into the engine, see commit.