* @param contents String containing the contents of the Resource
* @return Mocked Resource containing the contents of the String.
*/
public static Resource createMockedResource(String contents) {
try {
Resource entities = mock(Resource.class);
when(entities.exists()).thenReturn(true);
if (contents == null) {
when(entities.getInputStream()).thenReturn((InputStream) null);
} else {
InputStream inputStream = new ByteArrayInputStream(contents.getBytes());
when(entities.getInputStream()).thenReturn(inputStream);
}
return entities;
} catch (IOException e) {
throw new CedarRuntimeException("Error creating Resource: " + e.getMessage(), e);