Search in sources :

Example 1 with TxCompletionCondition

use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.

the class DSNMessageGenerator_generateDSNFailureMessageTest method createGenerator.

DSNMessageGenerator createGenerator() {
    DSNGenerator dsnGenerator = new DSNGenerator("Not Delivered:");
    TxCompletionCondition checker = new GeneralCompletionCondition();
    DSNFailureTextBodyPartGenerator textGenerator = new DefaultDSNFailureTextBodyPartGenerator("", "", "", "", "", HumanReadableTextAssemblerFactory.getInstance());
    return new DSNMessageGenerator(dsnGenerator, "postmaster", checker, "JUnitMTA", textGenerator);
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) GeneralCompletionCondition(org.nhindirect.monitor.condition.impl.GeneralCompletionCondition) DSNGenerator(org.nhindirect.common.mail.dsn.DSNGenerator) DefaultDSNFailureTextBodyPartGenerator(org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator) DSNFailureTextBodyPartGenerator(org.nhindirect.common.mail.dsn.DSNFailureTextBodyPartGenerator) DefaultDSNFailureTextBodyPartGenerator(org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator)

Example 2 with TxCompletionCondition

use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.

the class VariableCompletionCondition_isCompleteTest method testIsComplete_isTimely_assertNotComplete.

@SuppressWarnings("unchecked")
@Test
public void testIsComplete_isTimely_assertNotComplete() {
    TxCompletionCondition timelyCond = mock(TxCompletionCondition.class);
    TxCompletionCondition generalCond = mock(TxCompletionCondition.class);
    when(generalCond.isComplete((Collection<Tx>) any())).thenReturn(true);
    VariableCompletionCondition cond = new VariableCompletionCondition(timelyCond, generalCond);
    VariableCompletionCondition spy = spy(cond);
    Tx msgToTrack = mock(Tx.class);
    when(spy.getMessageToTrackInternal((Collection<Tx>) any())).thenReturn(msgToTrack);
    when(spy.isRelAndTimelyRequired((Tx) any())).thenReturn(true);
    assertFalse(spy.isComplete(null));
    verify(timelyCond, times(1)).isComplete((Collection<Tx>) any());
    verify(generalCond, never()).isComplete((Collection<Tx>) any());
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) Tx(org.nhindirect.common.tx.model.Tx) Test(org.junit.Test)

Example 3 with TxCompletionCondition

use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.

the class VariableCompletionCondition_isCompleteTest method testIsComplete_nullMessageToTrack_assertNull.

@SuppressWarnings("unchecked")
@Test
public void testIsComplete_nullMessageToTrack_assertNull() {
    TxCompletionCondition cond1 = mock(TxCompletionCondition.class);
    TxCompletionCondition cond2 = mock(TxCompletionCondition.class);
    VariableCompletionCondition cond = new VariableCompletionCondition(cond1, cond2);
    VariableCompletionCondition spy = spy(cond);
    when(spy.getMessageToTrackInternal((Collection<Tx>) any())).thenReturn(null);
    assertFalse(spy.isComplete(null));
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) Tx(org.nhindirect.common.tx.model.Tx) Test(org.junit.Test)

Example 4 with TxCompletionCondition

use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.

the class VariableCompletionCondition_isTimelyAndRequiredTest method testIsTimelyAndRequired_MDNOptionForTimely_assertTrue.

@Test
public void testIsTimelyAndRequired_MDNOptionForTimely_assertTrue() {
    TxCompletionCondition cond1 = mock(TxCompletionCondition.class);
    TxCompletionCondition cond2 = mock(TxCompletionCondition.class);
    VariableCompletionCondition cond = new VariableCompletionCondition(cond1, cond2);
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.DISPOSITION_OPTIONS.getType(), new TxDetail(TxDetailType.DISPOSITION_OPTIONS, MDNStandard.DispositionOption_TimelyAndReliable));
    Tx msg = new Tx(TxMessageType.IMF, details);
    assertTrue(cond.isRelAndTimelyRequired(msg));
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Example 5 with TxCompletionCondition

use of org.nhindirect.monitor.condition.TxCompletionCondition in project nhin-d by DirectProject.

the class VariableCompletionCondition_isTimelyAndRequiredTest method testIsTimelyAndRequired_MDNOptionNotForTimely_assertFalse.

@Test
public void testIsTimelyAndRequired_MDNOptionNotForTimely_assertFalse() {
    TxCompletionCondition cond1 = mock(TxCompletionCondition.class);
    TxCompletionCondition cond2 = mock(TxCompletionCondition.class);
    VariableCompletionCondition cond = new VariableCompletionCondition(cond1, cond2);
    Map<String, TxDetail> details = new HashMap<String, TxDetail>();
    details.put(TxDetailType.DISPOSITION_OPTIONS.getType(), new TxDetail(TxDetailType.DISPOSITION_OPTIONS, "X-NOT-TIMELY"));
    Tx msg = new Tx(TxMessageType.IMF, details);
    assertFalse(cond.isRelAndTimelyRequired(msg));
}
Also used : TxCompletionCondition(org.nhindirect.monitor.condition.TxCompletionCondition) Tx(org.nhindirect.common.tx.model.Tx) HashMap(java.util.HashMap) TxDetail(org.nhindirect.common.tx.model.TxDetail) Test(org.junit.Test)

Aggregations

TxCompletionCondition (org.nhindirect.monitor.condition.TxCompletionCondition)21 Test (org.junit.Test)20 Tx (org.nhindirect.common.tx.model.Tx)14 Exchange (org.apache.camel.Exchange)5 ArrayList (java.util.ArrayList)4 TxDetail (org.nhindirect.common.tx.model.TxDetail)4 HashMap (java.util.HashMap)3 Message (org.apache.camel.Message)3 TxTimeoutCondition (org.nhindirect.monitor.condition.TxTimeoutCondition)3 CamelContext (org.apache.camel.CamelContext)2 DefaultExchange (org.apache.camel.impl.DefaultExchange)2 DSNFailureTextBodyPartGenerator (org.nhindirect.common.mail.dsn.DSNFailureTextBodyPartGenerator)1 DSNGenerator (org.nhindirect.common.mail.dsn.DSNGenerator)1 DefaultDSNFailureTextBodyPartGenerator (org.nhindirect.common.mail.dsn.impl.DefaultDSNFailureTextBodyPartGenerator)1 GeneralCompletionCondition (org.nhindirect.monitor.condition.impl.GeneralCompletionCondition)1