Search in sources :

Example 16 with DefinitionSpace

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);
}
Also used : CarDataBase(io.vertigo.dynamo.search_2_4.data.domain.CarDataBase) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) CarSearchLoader(io.vertigo.dynamo.search_2_4.data.domain.CarSearchLoader) FacetDefinition(io.vertigo.dynamo.collections.metamodel.FacetDefinition) FacetedQueryDefinition(io.vertigo.dynamo.collections.metamodel.FacetedQueryDefinition)

Example 17 with DefinitionSpace

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);
}
Also used : Car(io.vertigo.dynamo.search_2_4.data.domain.Car) SearchIndexDefinition(io.vertigo.dynamo.search.metamodel.SearchIndexDefinition) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) Test(org.junit.Test)

Example 18 with DefinitionSpace

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()));
}
Also used : Role(io.vertigo.account.authorization.metamodel.Role) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) Test(org.junit.Test)

Example 19 with DefinitionSpace

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();
    }
}
Also used : Role(io.vertigo.persona.security.metamodel.Role) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 20 with DefinitionSpace

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));
}
Also used : Formatter(io.vertigo.dynamo.domain.metamodel.Formatter) DefinitionSpace(io.vertigo.core.definition.DefinitionSpace) Test(org.junit.Test)

Aggregations

DefinitionSpace (io.vertigo.core.definition.DefinitionSpace)29 Test (org.junit.Test)18 SearchIndexDefinition (io.vertigo.dynamo.search.metamodel.SearchIndexDefinition)9 Domain (io.vertigo.dynamo.domain.metamodel.Domain)6 FacetedQueryDefinition (io.vertigo.dynamo.collections.metamodel.FacetedQueryDefinition)4 DtDefinition (io.vertigo.dynamo.domain.metamodel.DtDefinition)4 TaskDefinition (io.vertigo.dynamo.task.metamodel.TaskDefinition)4 FormatterDefault (io.vertigo.dynamox.domain.formatter.FormatterDefault)4 ListFilter (io.vertigo.dynamo.collections.ListFilter)3 FacetDefinition (io.vertigo.dynamo.collections.metamodel.FacetDefinition)3 FormatterDefinition (io.vertigo.dynamo.domain.metamodel.FormatterDefinition)3 Task (io.vertigo.dynamo.task.model.Task)3 VTransactionWritable (io.vertigo.commons.transaction.VTransactionWritable)2 SqlConnection (io.vertigo.database.sql.connection.SqlConnection)2 DslDefinition (io.vertigo.dynamo.plugins.environment.dsl.dynamic.DslDefinition)2 Item (io.vertigo.dynamo.search.data.domain.Item)2 ItemDataBase (io.vertigo.dynamo.search.data.domain.ItemDataBase)2 Car (io.vertigo.dynamo.search_2_4.data.domain.Car)2 CarDataBase (io.vertigo.dynamo.search_2_4.data.domain.CarDataBase)2 TaskResult (io.vertigo.dynamo.task.model.TaskResult)2