@Test
public void testScopeMapperByNameAndCompany() throws Exception {

	String applicationName2 = "com.liferay.test2";
	ScopeMapper defaultScopeMapper = ScopeMapper.PASS_THROUGH_SCOPE_MAPPER;
	ScopeFinder scopeFinder = () -> scopesSet1;
	Builder builder = new Builder();
	ScopeLocatorImpl scopeLocatorImpl = builder.withScopeMappers(
		defaultScopeMapper,
		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(scope));
		Assert.assertThat(application2ScopeAliases, hasItem(scope));
	}
	ScopeMapper appScopeMapper = scope -> Collections.singleton(
		"app/" + scope);
	ScopeMapper companyScopeMapper = scope -> Collections.singleton(
		"company/" + scope);
	builder = new Builder();
	scopeLocatorImpl = builder.withScopeMappers(
		defaultScopeMapper,
		registrator -> {
			registrator.register(null, _APPLICATION_NAME, appScopeMapper);
			registrator.register(_COMPANY_ID, null, companyScopeMapper);
		}
	).withScopeFinders(
		registrator -> {
			registrator.register(
				_COMPANY_ID, _APPLICATION_NAME, scopeFinder);
			registrator.register(
				_COMPANY_ID, applicationName2, scopeFinder);
		}
	).build();
	Collection<String> application1ScopesAliases =
		scopeLocatorImpl.getScopeAliases(_COMPANY_ID, _APPLICATION_NAME);
	Collection<String> application2ScopesAliases =
		scopeLocatorImpl.getScopeAliases(_COMPANY_ID, applicationName2);
	for (String scope : scopesSet1) {
		Assert.assertThat(
			application1ScopesAliases,
			hasItems(
				appScopeMapper.map(
					scope
				).toArray(
					new String[0]
				)));
		Assert.assertThat(
			application2ScopesAliases,
			hasItems(
				companyScopeMapper.map(
					scope
				).toArray(
					new String[0]
				)));
	}
}