use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class AbstractSearchManagerTest method init.
/**
* Initialise l'index.
* @param indexName Nom de l'index
*/
protected final void init(final String indexName) {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
// On construit la BDD des voitures
carDataBase = new CarDataBase();
carDataBase.loadDatas();
final CarSearchLoader carSearchLoader = getApp().getComponentSpace().resolve(CarSearchLoader.class);
carSearchLoader.bindDataBase(carDataBase);
makeFacetDefinition = definitionSpace.resolve("FCT_MAKE_CAR", FacetDefinition.class);
yearFacetDefinition = definitionSpace.resolve("FCT_YEAR_CAR", FacetDefinition.class);
carIndexDefinition = definitionSpace.resolve(indexName, SearchIndexDefinition.class);
carFacetQueryDefinition = definitionSpace.resolve("QRY_CAR_FACET", FacetedQueryDefinition.class);
clean(carIndexDefinition);
}
use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class SearchManagerMultiIndexTest method testIndex.
/**
* Test de création de n enregistrements dans l'index.
* La création s'effectue dans une seule transaction mais sur deux indexes.
* Vérifie la capacité du système à gérer plusieurs indexes.
*/
@Test
public void testIndex() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final SearchIndexDefinition carIndexDefinition = definitionSpace.resolve(IDX_CAR, SearchIndexDefinition.class);
final SearchIndexDefinition carDynIndexDefinition = definitionSpace.resolve(IDX_DYNA_CAR, SearchIndexDefinition.class);
for (final Car car : carDataBase.getAllCars()) {
final SearchIndex<Car, Car> index = SearchIndex.createIndex(carIndexDefinition, car.getURI(), car);
searchManager.put(carIndexDefinition, index);
final SearchIndex<Car, Car> index2 = SearchIndex.createIndex(carDynIndexDefinition, car.getURI(), car);
searchManager.put(carDynIndexDefinition, index2);
}
waitIndexation();
final long sizeCar = query("*:*", carIndexDefinition);
Assert.assertEquals(carDataBase.size(), sizeCar);
final long sizeCarDyn = query("*:*", carDynIndexDefinition);
Assert.assertEquals(carDataBase.size(), sizeCarDyn);
}
use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class VSecurityManagerTest method testRole.
@Test
public void testRole() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final Role admin = definitionSpace.resolve("R_ADMIN", Role.class);
Assert.assertTrue("R_ADMIN".equals(admin.getName()));
final Role secretary = definitionSpace.resolve("R_SECRETARY", Role.class);
Assert.assertTrue("R_SECRETARY".equals(secretary.getName()));
}
use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class VSecurityManagerTest method testAccess.
@Test
public void testAccess() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final Role admin = definitionSpace.resolve("R_ADMIN", Role.class);
final Role manager = definitionSpace.resolve("R_MANAGER", Role.class);
final Role secretary = definitionSpace.resolve("R_SECRETARY", Role.class);
final UserSession userSession = securityManager.<PersonaUserSession>createUserSession().addRole(admin).addRole(manager);
try {
securityManager.startCurrentUserSession(userSession);
final Set<Role> roles = new HashSet<>();
roles.add(admin);
roles.add(secretary);
Assert.assertTrue(securityManager.hasRole(roles));
roles.clear();
roles.add(secretary);
Assert.assertFalse(securityManager.hasRole(roles));
// Si aucun droit necessaire alors c'est bon
roles.clear();
Assert.assertTrue(securityManager.hasRole(roles));
} finally {
securityManager.stopCurrentUserSession();
}
}
use of io.vertigo.core.definition.DefinitionSpace in project vertigo by KleeGroup.
the class OOMEnvironmentManagerTest method testDefaultBooleanFormatter.
@Test
public void testDefaultBooleanFormatter() {
final DefinitionSpace definitionSpace = getApp().getDefinitionSpace();
final Formatter formatter = definitionSpace.resolve("FMT_DEFAULT", FormatterDefinition.class);
Assert.assertEquals("MyTrue", formatter.valueToString(true, DataType.Boolean));
}
Aggregations