    @Test
    public void createShouldHandleResourceTypeServiceFailure() throws EntitlementException {

        //given
        CreateRequest mockCreateRequest = mock(CreateRequest.class);
        JsonValue content = mock(JsonValue.class);

        given(mockCreateRequest.getContent()).willReturn(content);
        given(mockCreateRequest.getNewResourceId()).willReturn(null);

        given(content.toString()).willReturn(jsonResourceType);

        // simulate failure in the resource type service
        Throwable t = new EntitlementException(EntitlementException.RESOURCE_TYPE_ALREADY_EXISTS);
        Mockito.doThrow(t).when(resourceTypeService).saveResourceType(any(Subject.class), anyString(), any
                (ResourceType.class));

        //when
        Promise<ResourceResponse, ResourceException> promise =
                resourceTypesResource.createInstance(mockServerContext, mockCreateRequest);

        //then
        assertResourcePromiseFailedWithCodes(promise, ResourceException.CONFLICT,
                EntitlementException.RESOURCE_TYPE_ALREADY_EXISTS);
    }