Search in sources :

Example 46 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project flow by vaadin.

the class BinderTest method readBean_converterThrows_exceptionHandlerSet_bindingExceptionIsThrown.

@Test(expected = BindingException.class)
public void readBean_converterThrows_exceptionHandlerSet_bindingExceptionIsThrown() {
    TestTextField testField = new TestTextField();
    setExceptionHandler();
    binder.forField(testField).withConverter(Converter.<String, String>from(name -> {
        throw new NullPointerException();
    }, name -> name)).bind(Person::getFirstName, Person::setFirstName).read(new Person());
}
Also used : CoreMatchers(org.hamcrest.CoreMatchers) HasValue(com.vaadin.flow.component.HasValue) CurrentInstance(com.vaadin.flow.internal.CurrentInstance) Person(com.vaadin.flow.tests.data.bean.Person) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HashMap(java.util.HashMap) StringToDoubleConverter(com.vaadin.flow.data.converter.StringToDoubleConverter) AtomicReference(java.util.concurrent.atomic.AtomicReference) StringUtils(org.apache.commons.lang3.StringUtils) NumberFormat(java.text.NumberFormat) Assert.assertSame(org.junit.Assert.assertSame) BigDecimal(java.math.BigDecimal) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Locale(java.util.Locale) IntegerRangeValidator(com.vaadin.flow.data.validator.IntegerRangeValidator) Map(java.util.Map) After(org.junit.After) BindingBuilder(com.vaadin.flow.data.binder.Binder.BindingBuilder) UI(com.vaadin.flow.component.UI) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) ExpectedException(org.junit.rules.ExpectedException) Before(org.junit.Before) StringToIntegerConverter(com.vaadin.flow.data.converter.StringToIntegerConverter) Assert.assertNotNull(org.junit.Assert.assertNotNull) DecimalFormat(java.text.DecimalFormat) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) StringToBigDecimalConverter(com.vaadin.flow.data.converter.StringToBigDecimalConverter) Assert.assertNotEquals(org.junit.Assert.assertNotEquals) Serializable(java.io.Serializable) Objects(java.util.Objects) Converter(com.vaadin.flow.data.converter.Converter) StringLengthValidator(com.vaadin.flow.data.validator.StringLengthValidator) Stream(java.util.stream.Stream) Rule(org.junit.Rule) Assert.assertNull(org.junit.Assert.assertNull) Assert.assertFalse(org.junit.Assert.assertFalse) Optional(java.util.Optional) NotEmptyValidator(com.vaadin.flow.data.validator.NotEmptyValidator) Assert(org.junit.Assert) Binding(com.vaadin.flow.data.binder.Binder.Binding) TestTextField(com.vaadin.flow.data.binder.testcomponents.TestTextField) Sex(com.vaadin.flow.tests.data.bean.Sex) Matchers.containsString(org.hamcrest.Matchers.containsString) Assert.assertEquals(org.junit.Assert.assertEquals) TestTextField(com.vaadin.flow.data.binder.testcomponents.TestTextField) Person(com.vaadin.flow.tests.data.bean.Person) Test(org.junit.Test)

Example 47 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project cas by apereo.

the class PrincipalAttributeRepositoryFetcher method retrieve.

/**
 * Retrieve person attributes.
 *
 * @return the map
 */
public Map<String, List<Object>> retrieve() {
    var filter = IPersonAttributeDaoFilter.alwaysChoose();
    if (!activeAttributeRepositoryIdentifiers.isEmpty()) {
        val repoIdsArray = activeAttributeRepositoryIdentifiers.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
        LOGGER.trace("Active attribute repository identifiers [{}]", activeAttributeRepositoryIdentifiers);
        filter = dao -> Arrays.stream(dao.getId()).anyMatch(daoId -> daoId.equalsIgnoreCase(IPersonAttributeDao.WILDCARD) || StringUtils.equalsAnyIgnoreCase(daoId, repoIdsArray) || StringUtils.equalsAnyIgnoreCase(IPersonAttributeDao.WILDCARD, repoIdsArray));
    }
    val query = new LinkedHashMap<String, Object>();
    if (currentPrincipal != null) {
        query.put("principal", currentPrincipal.getId());
        query.putAll(currentPrincipal.getAttributes());
    }
    query.putAll(queryAttributes);
    query.put("username", principalId.trim());
    LOGGER.debug("Fetching person attributes for query [{}]", query);
    val people = attributeRepository.getPeople(query, filter);
    if (people == null || people.isEmpty()) {
        LOGGER.warn("No person records were fetched from attribute repositories for [{}]", query);
        return new HashMap<>(0);
    }
    if (people.size() > 1) {
        LOGGER.warn("Multiple records were found for [{}] from attribute repositories for query [{}]. The records are [{}], " + "and CAS will only pick the first person record from the results.", principalId, query, people);
    }
    val person = people.iterator().next();
    LOGGER.debug("Retrieved person [{}] from attribute repositories for query [{}]", person, query);
    return person.getAttributes();
}
Also used : lombok.val(lombok.val) Arrays(java.util.Arrays) Getter(lombok.Getter) SuperBuilder(lombok.experimental.SuperBuilder) lombok.val(lombok.val) Set(java.util.Set) ArrayUtils(org.apache.commons.lang3.ArrayUtils) HashMap(java.util.HashMap) StringUtils(org.apache.commons.lang3.StringUtils) IPersonAttributeDao(org.apereo.services.persondir.IPersonAttributeDao) IPersonAttributeDaoFilter(org.apereo.services.persondir.IPersonAttributeDaoFilter) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Builder(lombok.Builder) Map(java.util.Map) Principal(org.apereo.cas.authentication.principal.Principal) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 48 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.

the class TestBulkWithin method testBulkWithinVertexCompileStep.

@Test
public void testBulkWithinVertexCompileStep() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
        this.sqlgGraph.tx().normalBatchModeOn();
    }
    Vertex god = this.sqlgGraph.addVertex(T.label, "God");
    List<String> uuids = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        String uuid = UUID.randomUUID().toString();
        uuids.add(uuid);
        Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", uuid);
        god.addEdge("creator", person);
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    testBulkWithinVertexCompileStep_assert(this.sqlgGraph, god, uuids);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        testBulkWithinVertexCompileStep_assert(this.sqlgGraph1, god, uuids);
    }
    stopWatch.stop();
    System.out.println(stopWatch.toString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ArrayList(java.util.ArrayList) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 49 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.

the class TestBulkWithin method testBulkWithinWithPercentageInJoinProperties.

@Test
public void testBulkWithinWithPercentageInJoinProperties() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
        this.sqlgGraph.tx().normalBatchModeOn();
    }
    Vertex god = this.sqlgGraph.addVertex(T.label, "God");
    List<String> uuids = new ArrayList<>();
    for (int i = 0; i < 100; i++) {
        String uuid = UUID.randomUUID().toString();
        uuids.add("\"BLRNC5->CXC4030052~%%%~FAJ1211373~%%%~2015-07-19~%%%~9999-12-31~%%%~Enabled~%%%~Licensed~%%%~Improved~%%%~compressed~%%%~mode~%%%~handling.~%%%~Restricted:~%%%~\"\"Partial.~%%%~Feature~%%%~is~%%%~restricted~%%%~in~%%%~RNC~%%%~W12B~%%%~SW.~%%%~RNC~%%%~W13.0.1.1~%%%~or~%%%~later~%%%~SW~%%%~is~%%%~required~%%%~in~%%%~order~%%%~to~%%%~run~%%%~this~%%%~feature.~%%%~For~%%%~RBS~%%%~W12.1.2.2/~%%%~W13.0.0.0~%%%~or~%%%~later~%%%~is~%%%~required.~%%%~OSS-RC~%%%~12.2~%%%~or~%%%~later~%%%~is~%%%~required.\"\".~%%%~GA:~%%%~W13A\"" + uuid);
        Vertex person = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", "\"BLRNC5->CXC4030052~%%%~FAJ1211373~%%%~2015-07-19~%%%~9999-12-31~%%%~Enabled~%%%~Licensed~%%%~Improved~%%%~compressed~%%%~mode~%%%~handling.~%%%~Restricted:~%%%~\"\"Partial.~%%%~Feature~%%%~is~%%%~restricted~%%%~in~%%%~RNC~%%%~W12B~%%%~SW.~%%%~RNC~%%%~W13.0.1.1~%%%~or~%%%~later~%%%~SW~%%%~is~%%%~required~%%%~in~%%%~order~%%%~to~%%%~run~%%%~this~%%%~feature.~%%%~For~%%%~RBS~%%%~W12.1.2.2/~%%%~W13.0.0.0~%%%~or~%%%~later~%%%~is~%%%~required.~%%%~OSS-RC~%%%~12.2~%%%~or~%%%~later~%%%~is~%%%~required.\"\".~%%%~GA:~%%%~W13A\"" + uuid);
        god.addEdge("creator", person);
    }
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    testBulkWithinWithPercentageInJoinProperties_assert(this.sqlgGraph, uuids);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        testBulkWithinWithPercentageInJoinProperties_assert(this.sqlgGraph1, uuids);
    }
    stopWatch.stop();
    System.out.println(stopWatch.toString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) ArrayList(java.util.ArrayList) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Example 50 with Person

use of org.apache.commons.lang3.builder.ToStringStyleTest.Person in project sqlg by pietermartin.

the class TestBulkWithin method testBulkWithinMultipleHasContainers.

@Test
public void testBulkWithinMultipleHasContainers() throws InterruptedException {
    StopWatch stopWatch = new StopWatch();
    stopWatch.start();
    if (this.sqlgGraph.getSqlDialect().supportsBatchMode()) {
        this.sqlgGraph.tx().normalBatchModeOn();
    }
    Vertex god = this.sqlgGraph.addVertex(T.label, "God");
    Vertex person1 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 1, "name", "pete");
    god.addEdge("creator", person1);
    Vertex person2 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 2, "name", "pete");
    god.addEdge("creator", person2);
    Vertex person3 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 3, "name", "john");
    god.addEdge("creator", person3);
    Vertex person4 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 4, "name", "pete");
    god.addEdge("creator", person4);
    Vertex person5 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 5, "name", "pete");
    god.addEdge("creator", person5);
    Vertex person6 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 6, "name", "pete");
    god.addEdge("creator", person6);
    Vertex person7 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 7, "name", "pete");
    god.addEdge("creator", person7);
    Vertex person8 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 8, "name", "pete");
    god.addEdge("creator", person8);
    Vertex person9 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 9, "name", "pete");
    god.addEdge("creator", person9);
    Vertex person10 = this.sqlgGraph.addVertex(T.label, "Person", "idNumber", 10, "name", "pete");
    god.addEdge("creator", person10);
    this.sqlgGraph.tx().commit();
    stopWatch.stop();
    System.out.println(stopWatch.toString());
    stopWatch.reset();
    stopWatch.start();
    testBulkWithinMultipleHasContrainers_assert(this.sqlgGraph);
    if (this.sqlgGraph1 != null) {
        Thread.sleep(SLEEP_TIME);
        testBulkWithinMultipleHasContrainers_assert(this.sqlgGraph);
    }
    stopWatch.stop();
    System.out.println(stopWatch.toString());
}
Also used : Vertex(org.apache.tinkerpop.gremlin.structure.Vertex) StopWatch(org.apache.commons.lang3.time.StopWatch) BaseTest(org.umlg.sqlg.test.BaseTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)43 BaseTest (org.umlg.sqlg.test.BaseTest)24 StopWatch (org.apache.commons.lang3.time.StopWatch)23 StringUtils (org.apache.commons.lang3.StringUtils)21 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)20 HashMap (java.util.HashMap)18 Map (java.util.Map)17 Optional (java.util.Optional)16 BigDecimal (java.math.BigDecimal)15 Assert (org.junit.Assert)15 Locale (java.util.Locale)14 HasValue (com.vaadin.flow.component.HasValue)13 UI (com.vaadin.flow.component.UI)13 Binding (com.vaadin.flow.data.binder.Binder.Binding)13 BindingBuilder (com.vaadin.flow.data.binder.Binder.BindingBuilder)13 TestTextField (com.vaadin.flow.data.binder.testcomponents.TestTextField)13 Converter (com.vaadin.flow.data.converter.Converter)13 StringToBigDecimalConverter (com.vaadin.flow.data.converter.StringToBigDecimalConverter)13 StringToDoubleConverter (com.vaadin.flow.data.converter.StringToDoubleConverter)13 StringToIntegerConverter (com.vaadin.flow.data.converter.StringToIntegerConverter)13