@Test
public void testPrefixHandlerFactoryByNameAndCompany() throws Exception {

	String applicationName2 = "com.liferay.test2";
	PrefixHandler defaultPrefixHandler = target -> "default/" + target;
	ScopeFinder scopeFinder = () -> scopesSet1;
	Builder builder = new Builder();
	ScopeLocatorImpl scopeLocatorImpl = builder.withPrefixHandlerFactories(
		propertyAccessor -> defaultPrefixHandler,
		registrator -> {
		}
	).withScopeFinders(
		registrator -> {
			registrator.register(
				_COMPANY_ID, _APPLICATION_NAME, scopeFinder);
			registrator.register(
				_COMPANY_ID, applicationName2, scopeFinder);
		}
	).build();
	Collection<String> application1ScopeAliases =
		scopeLocatorImpl.getScopeAliases(_COMPANY_ID, _APPLICATION_NAME);
	Collection<String> application2ScopeAliases =
		scopeLocatorImpl.getScopeAliases(_COMPANY_ID, applicationName2);
	for (String scope : scopesSet1) {
		Assert.assertThat(
			application1ScopeAliases,
			hasItem(defaultPrefixHandler.addPrefix(scope)));
		Assert.assertThat(
			application2ScopeAliases,
			hasItem(defaultPrefixHandler.addPrefix(scope)));
	}
	PrefixHandler appPrefixHandler = target -> "app/" + target;
	PrefixHandler companyPrefixHandler = target -> "company/" + target;
	builder = new Builder();
	scopeLocatorImpl = builder.withPrefixHandlerFactories(
		propertyAccessor -> defaultPrefixHandler,
		registrator -> {
			registrator.register(
				null, _APPLICATION_NAME,
				propertyAccessor -> appPrefixHandler);
			registrator.register(
				_COMPANY_ID, null,
				propertyAccessor -> companyPrefixHandler);
		}
	).withScopeFinders(
		registrator -> {
			registrator.register(
				_COMPANY_ID, _APPLICATION_NAME, scopeFinder);
			registrator.register(
				_COMPANY_ID, applicationName2, scopeFinder);
		}
	).build();
	application1ScopeAliases = scopeLocatorImpl.getScopeAliases(
		_COMPANY_ID, _APPLICATION_NAME);
	application2ScopeAliases = scopeLocatorImpl.getScopeAliases(
		_COMPANY_ID, applicationName2);
	for (String scope : scopesSet1) {
		Assert.assertThat(
			application1ScopeAliases,
			hasItem(appPrefixHandler.addPrefix(scope)));
		Assert.assertThat(
			application2ScopeAliases,
			hasItem(companyPrefixHandler.addPrefix(scope)));
	}
}