@Before
  public void setUp() {
    this.serializer = new DefaultStringEntityReferenceSerializer();

    this.resolver = new DefaultStringEntityReferenceResolver();
    final EntityReferenceValueProvider mockValueProvider =
        this.mockery.mock(EntityReferenceValueProvider.class);
    ReflectionUtils.setFieldValue(this.resolver, "provider", mockValueProvider);

    this.mockery.checking(
        new Expectations() {
          {
            allowing(mockValueProvider).getDefaultValue(EntityType.WIKI);
            will(returnValue(DEFAULT_WIKI));
            allowing(mockValueProvider).getDefaultValue(EntityType.SPACE);
            will(returnValue(DEFAULT_SPACE));
            allowing(mockValueProvider).getDefaultValue(EntityType.DOCUMENT);
            will(returnValue(DEFAULT_PAGE));
            allowing(mockValueProvider).getDefaultValue(EntityType.ATTACHMENT);
            will(returnValue(DEFAULT_ATTACHMENT));
            allowing(mockValueProvider).getDefaultValue(EntityType.OBJECT);
            will(returnValue(DEFAULT_OBJECT));
            allowing(mockValueProvider).getDefaultValue(EntityType.OBJECT_PROPERTY);
            will(returnValue(DEFAULT_OBJECT_PROPERTY));
            allowing(mockValueProvider).getDefaultValue(EntityType.CLASS_PROPERTY);
            will(returnValue(DEFAULT_CLASS_PROPERTY));
          }
        });
  }
  // Only do once, because components are stored statically within various classes,
  // which causes problems with changing genetics mocks
  @BeforeClass
  @SuppressWarnings("unchecked")
  public static void setupComponents() throws ComponentLookupException, CacheException {
    ComponentManager componentManager = mock(ComponentManager.class);
    Provider<ComponentManager> mockProvider = mock(Provider.class);
    // This is a bit fragile, let's hope the field name doesn't change
    ReflectionUtils.setFieldValue(new ComponentManagerRegistry(), "cmProvider", mockProvider);
    when(mockProvider.get()).thenReturn(componentManager);

    CacheManager cacheManager = mock(CacheManager.class);
    when(componentManager.getInstance(CacheManager.class)).thenReturn(cacheManager);

    CacheFactory cacheFactory = mock(CacheFactory.class);
    when(cacheManager.getLocalCacheFactory()).thenReturn(cacheFactory);

    Cache<Exome> cache = mock(Cache.class);
    doReturn(cache).when(cacheFactory).newCache(Matchers.any(CacheConfiguration.class));
    doReturn(null).when(cache).get(Matchers.anyString());

    // Wire up mocked genetics
    exomeManager = mock(ExomeManager.class);
    when(componentManager.getInstance(ExomeManager.class, "exomiser")).thenReturn(exomeManager);

    // Use a real GenotypeManager
    PatientGenotypeManager genotypeManager = new DefaultPatientGenotypeManager();
    when(componentManager.getInstance(PatientGenotypeManager.class)).thenReturn(genotypeManager);
  }