Search in sources :

Example 1 with XtendBeanGenerator

use of ch.vorburger.xtendbeans.XtendBeanGenerator in project genius by opendaylight.

the class InstructionClearActionsTest method xtendBeanGenerator.

@Test
public void xtendBeanGenerator() {
    XtendBeanGenerator generator = new XtendBeanGenerator();
    assertEquals("new InstructionClearActions", generator.getExpression(INSTRUCTION_INFO));
}
Also used : XtendBeanGenerator(ch.vorburger.xtendbeans.XtendBeanGenerator) Test(org.junit.Test)

Example 2 with XtendBeanGenerator

use of ch.vorburger.xtendbeans.XtendBeanGenerator in project genius by opendaylight.

the class InstructionGotoTableTest method xtendBeanGenerator.

@Test
public void xtendBeanGenerator() {
    XtendBeanGenerator generator = new XtendBeanGenerator();
    assertEquals("new InstructionGotoTable(1 as short)", generator.getExpression(INSTRUCTION_INFO));
}
Also used : XtendBeanGenerator(ch.vorburger.xtendbeans.XtendBeanGenerator) Test(org.junit.Test)

Example 3 with XtendBeanGenerator

use of ch.vorburger.xtendbeans.XtendBeanGenerator in project genius by opendaylight.

the class InstructionWriteMetadataTest method xtendBeanGenerator.

@Test
public void xtendBeanGenerator() {
    XtendBeanGenerator generator = new XtendBeanGenerator();
    assertEquals("new InstructionWriteMetadata(1bi, 10bi)", generator.getExpression(INSTRUCTION_INFO));
}
Also used : XtendBeanGenerator(ch.vorburger.xtendbeans.XtendBeanGenerator) Test(org.junit.Test)

Example 4 with XtendBeanGenerator

use of ch.vorburger.xtendbeans.XtendBeanGenerator in project genius by opendaylight.

the class TestIMdsalApiManager method assertFlowsInAnyOrder.

// ComparisonException doesn’t allow us to keep the cause (which we don’t care about anyway)
@SuppressWarnings("checkstyle:AvoidHidingCauseException")
public synchronized void assertFlowsInAnyOrder(Iterable<FlowEntity> expectedFlows) {
    checkNonEmptyFlows(expectedFlows);
    // TODO Support Iterable <-> List directly within XtendBeanGenerator
    List<FlowEntity> expectedFlowsAsNewArrayList = Lists.newArrayList(expectedFlows);
    List<FlowEntity> sortedFlows = sortFlows(flows);
    List<FlowEntity> sortedExpectedFlows = sortFlows(expectedFlowsAsNewArrayList);
    // System#identityHashCode even less so.
    try {
        assertThat(sortedFlows).containsExactlyElementsIn(sortedExpectedFlows);
    } catch (AssertionError e) {
        // We LOG the AssertionError just for clarity why containsExactlyElementsIn() failed
        LOG.warn("assert containsExactlyElementsIn() failed", e);
        // We LOG the expected and actual flow in case of a failed assertion
        // because, even though that is typically just a HUGE String that's
        // hard to read (the diff printed subsequently by assertEqualBeans
        // is, much, more readable), there are cases when looking more closely
        // at the full toString() output of the flows is still useful, so:
        // TIP: Use e.g. 'wdiff -n expected.txt actual.txt | colordiff' to compare these!
        LOG.warn("assert failed [order ignored!]; expected flows: {}", sortedExpectedFlows);
        LOG.warn("assert failed [order ignored!]; actual flows  : {}", sortedFlows);
        // The point of now also doing assertEqualBeans() is just that its output,
        // in case of a comparison failure, is *A LOT* more clearly readable
        // than what G Truth (or Hamcrest) can do based on toString.
        assertEqualBeans(sortedExpectedFlows, sortedFlows);
        if (sortedExpectedFlows.toString().equals(sortedFlows.toString()) && !sortedExpectedFlows.equals(sortedFlows)) {
            fail("Suspected toString, missing getter, equals (hashCode) bug in FlowEntity related class!!! :-(");
        }
        throw new ComparisonFailure("assertEqualBeans() MUST fail - given that the assertThat.containsExactlyElementsIn() just failed!" + // AssertDataObjects, but for FlowEntity it's the same... it only makes a difference for DataObjects
        " What is missing in: " + new XtendBeanGenerator().getExpression(sortedFlows), sortedExpectedFlows.toString(), sortedFlows.toString());
    // If this ^^^ occurs, then there is probably a bug in ch.vorburger.xtendbeans
    }
}
Also used : XtendBeanGenerator(ch.vorburger.xtendbeans.XtendBeanGenerator) ComparisonFailure(org.junit.ComparisonFailure) FlowEntity(org.opendaylight.genius.mdsalutil.FlowEntity)

Example 5 with XtendBeanGenerator

use of ch.vorburger.xtendbeans.XtendBeanGenerator in project genius by opendaylight.

the class InstructionApplyActionsTest method xtendBeanGenerator.

@Test
public void xtendBeanGenerator() {
    XtendBeanGenerator generator = new XtendBeanGenerator();
    assertEquals("new InstructionApplyActions(#[\n" + "    (new ActionGroupBuilder => [\n" + "        groupId = 1L\n" + "    ]).build()\n" + "])", generator.getExpression(INSTRUCTION_INFO));
}
Also used : XtendBeanGenerator(ch.vorburger.xtendbeans.XtendBeanGenerator) Test(org.junit.Test)

Aggregations

XtendBeanGenerator (ch.vorburger.xtendbeans.XtendBeanGenerator)7 Test (org.junit.Test)6 ComparisonFailure (org.junit.ComparisonFailure)1 FlowEntity (org.opendaylight.genius.mdsalutil.FlowEntity)1