Example usage for org.apache.commons.lang3.mutable MutableBoolean setTrue

List of usage examples for org.apache.commons.lang3.mutable MutableBoolean setTrue

Introduction

In this page you can find the example usage for org.apache.commons.lang3.mutable MutableBoolean setTrue.

Prototype

public void setTrue() 

Source Link

Document

Sets the value to false.

Usage

From source file:org.jbpm.bpmn2.IntermediateEventTest.java

@Test
public void testSignalBoundaryNonEffectiveEvent() throws Exception {
    final String signal = "signalTest";
    final MutableBoolean eventAfterNodeLeftTriggered = new MutableBoolean(false);
    KieBase kbase = createKnowledgeBase("BPMN2-BoundaryEventWithNonEffectiveSignal.bpmn2");
    StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);

    ksession.addEventListener(new DefaultProcessEventListener() {
        @Override/*from  w w  w .jav  a 2  s.c  o m*/
        public void afterNodeLeft(ProcessNodeLeftEvent event) {
            // BoundaryEventNodeInstance
            if (signal.equals(event.getNodeInstance().getNodeName())) {
                eventAfterNodeLeftTriggered.setTrue();
            }
        }
    });
    ProcessInstance processInstance = ksession.startProcess("BoundaryEventWithNonEffectiveSignal");

    ksession.signalEvent(signal, signal);

    // outer human work
    ksession.getWorkItemManager().completeWorkItem(handler.getWorkItem().getId(), null);

    // inner human task
    ksession.getWorkItemManager().completeWorkItem(handler.getWorkItem().getId(), null);

    assertProcessInstanceFinished(processInstance, ksession);
    assertThat(eventAfterNodeLeftTriggered.isFalse()).isTrue();
}

From source file:org.onosproject.store.ecmap.MapDbPersistentStore.java

private void putInternal(K key, V value, Timestamp timestamp) {
    byte[] keyBytes = serializer.encode(key);
    byte[] removedBytes = tombstones.get(keyBytes);

    Timestamp removed = removedBytes == null ? null : serializer.decode(removedBytes);
    if (removed != null && removed.isNewerThan(timestamp)) {
        return;//from ww  w  .j av  a  2s . c  om
    }

    final MutableBoolean updated = new MutableBoolean(false);

    items.compute(keyBytes, (k, existingBytes) -> {
        Timestamped<V> existing = existingBytes == null ? null : serializer.decode(existingBytes);
        if (existing != null && existing.isNewerThan(timestamp)) {
            updated.setFalse();
            return existingBytes;
        } else {
            updated.setTrue();
            return serializer.encode(new Timestamped<>(value, timestamp));
        }
    });

    boolean success = updated.booleanValue();

    if (success && removed != null) {
        tombstones.remove(keyBytes, removedBytes);
    }

    database.commit();
}

From source file:org.onosproject.store.ecmap.MapDbPersistentStore.java

private void removeInternal(K key, Timestamp timestamp) {
    byte[] keyBytes = serializer.encode(key);

    final MutableBoolean updated = new MutableBoolean(false);

    items.compute(keyBytes, (k, existingBytes) -> {
        Timestamp existing = existingBytes == null ? null : serializer.decode(existingBytes);
        if (existing != null && existing.isNewerThan(timestamp)) {
            updated.setFalse();/*from   ww w  .  j  av  a  2 s .  co  m*/
            return existingBytes;
        } else {
            updated.setTrue();
            // remove from items map
            return null;
        }
    });

    if (!updated.booleanValue()) {
        return;
    }

    byte[] timestampBytes = serializer.encode(timestamp);
    byte[] removedBytes = tombstones.get(keyBytes);

    Timestamp removedTimestamp = removedBytes == null ? null : serializer.decode(removedBytes);
    if (removedTimestamp == null) {
        tombstones.putIfAbsent(keyBytes, timestampBytes);
    } else if (timestamp.isNewerThan(removedTimestamp)) {
        tombstones.replace(keyBytes, removedBytes, timestampBytes);
    }

    database.commit();
}

From source file:org.vaadin.viritin.FilterableListContainerTest.java

@Test
public void clearFilters() {
    final List<Person> listOfPersons = getListOfPersons(100);
    FilterableListContainer<Person> container = new FilterableListContainer<>(listOfPersons);
    container.addContainerFilter(new SimpleStringFilter("firstName", "First1", true, true));
    Assert.assertNotSame(listOfPersons.size(), container.size());
    container.removeAllContainerFilters();
    Assert.assertEquals(listOfPersons.size(), container.size());
    container.addContainerFilter(new SimpleStringFilter("firstName", "foobar", true, true));
    Assert.assertEquals(0, container.size());

    final MutableBoolean fired = new MutableBoolean(false);
    container.addListener(new Container.ItemSetChangeListener() {
        @Override/*from  w w  w  . j a  v a 2  s . c o  m*/
        public void containerItemSetChange(Container.ItemSetChangeEvent event) {
            fired.setTrue();
        }
    });
    container.removeAllContainerFilters();
    Assert.assertTrue(fired.booleanValue());
    Assert.assertEquals(listOfPersons.size(), container.size());
}

From source file:org.xwiki.notifications.preferences.script.NotificationPreferenceScriptServiceTest.java

@Test
public void saveNotificationPreferences() throws Exception {
    DocumentReference userRef = new DocumentReference("xwiki", "XWiki", "UserA");

    NotificationPreferenceImpl existingPref1 = new NotificationPreferenceImpl(true, NotificationFormat.ALERT,
            "create");
    NotificationPreferenceImpl existingPref2 = new NotificationPreferenceImpl(true, NotificationFormat.EMAIL,
            "update");
    NotificationPreferenceImpl existingPref3 = new NotificationPreferenceImpl(false, NotificationFormat.EMAIL,
            "delete");

    when(notificationPreferenceManager.getAllPreferences(eq(userRef)))
            .thenReturn(Arrays.asList(existingPref1, existingPref2, existingPref3));

    final MutableBoolean isOk = new MutableBoolean(false);
    doAnswer(invocationOnMock -> {//from w  ww . jav  a  2  s  .  c  o  m
        List<NotificationPreference> prefsToSave = invocationOnMock.getArgument(0);
        // 1 of the preferences contained in the JSON file should be saved because the inherited preference
        // is the same
        assertEquals(9, prefsToSave.size());

        assertTrue(prefsToSave.contains(existingPref1));
        assertTrue(prefsToSave.contains(existingPref2));
        assertFalse(prefsToSave.contains(existingPref3));

        isOk.setTrue();
        return true;
    }).when(notificationPreferenceManager).savePreferences(any(List.class));

    mocker.getComponentUnderTest().saveNotificationPreferences(
            IOUtils.toString(getClass().getResourceAsStream("/preferences.json")), userRef);

    assertTrue(isOk.booleanValue());
}