Search in sources :

Example 1 with TestObjects

use of org.finos.symphony.toolkit.workflow.fixture.TestObjects in project spring-bot by finos.

the class TestFormMessageML method createAxesWorkResponse.

protected WorkResponse createAxesWorkResponse(WorkMode wm) {
    TestObject a1 = new TestObject("83274239874", true, true, "rob@example.com", 234786, 2138);
    TestObject a2 = new TestObject("AUD274239874", true, false, "gregb@example.com", 2386, new BigDecimal("234823498.573"));
    TestObjects a = new TestObjects(Arrays.asList(a1, a2));
    WorkResponse wr = createWorkAddSubmit(wm, a);
    return wr;
}
Also used : TestObjects(org.finos.symphony.toolkit.workflow.fixture.TestObjects) TestObject(org.finos.symphony.toolkit.workflow.fixture.TestObject) WorkResponse(org.finos.symphony.toolkit.workflow.response.WorkResponse) BigDecimal(java.math.BigDecimal)

Example 2 with TestObjects

use of org.finos.symphony.toolkit.workflow.fixture.TestObjects in project spring-bot by finos.

the class TestHistory method testGetLast.

@Test
public void testGetLast() {
    TestObjects to = new TestObjects();
    Mockito.when(messagesApi.v1MessageSearchPost(Mockito.any(), Mockito.isNull(), Mockito.isNull(), Mockito.anyInt(), Mockito.anyInt(), Mockito.any(), Mockito.any())).thenAnswer(a -> {
        V4MessageList out = new V4MessageList();
        out.addAll(Arrays.asList(makeMessage(to)));
        return out;
    });
    TestObjects out = mh.getLastFromHistory(TestObjects.class, new SymphonyRoom("someroom", "abc123")).orElseThrow(() -> new RuntimeException());
    Assertions.assertEquals(out, to);
    Assertions.assertFalse(out == to);
}
Also used : V4MessageList(com.symphony.api.model.V4MessageList) TestObjects(org.finos.symphony.toolkit.workflow.fixture.TestObjects) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) Test(org.junit.jupiter.api.Test)

Example 3 with TestObjects

use of org.finos.symphony.toolkit.workflow.fixture.TestObjects in project spring-bot by finos.

the class TestEntityJsonConversion method testObjects.

@Test
public void testObjects() throws Exception {
    TestObject a1 = new TestObject("83274239874", true, true, "rob@example.com", 234786, 2138);
    TestObject a2 = new TestObject("AUD274239874", true, false, "gregb@example.com", 2386, new BigDecimal("234823498.573"));
    TestObjects a = new TestObjects(Arrays.asList(a1, a2));
    String out = toWorkflowJson(a);
    compare("{\"workflow_001\":{\"type\":\"org.finos.symphony.toolkit.workflow.fixture.testObjects\",\"version\":\"1.0\",\"items\":[{\"type\":\"org.finos.symphony.toolkit.workflow.fixture.testObject\",\"version\":\"1.0\",\"isin\":\"83274239874\",\"bidAxed\":true,\"askAxed\":true,\"creator\":\"rob@example.com\",\"bidQty\":234786,\"askQty\":2138},{\"type\":\"org.finos.symphony.toolkit.workflow.fixture.testObject\",\"version\":\"1.0\",\"isin\":\"AUD274239874\",\"bidAxed\":true,\"askAxed\":false,\"creator\":\"gregb@example.com\",\"bidQty\":2386,\"askQty\":234823498.573}]}}", out);
    TestObjects b = (TestObjects) readWorkflowValue(out);
    Assertions.assertEquals(a, b);
}
Also used : TestObjects(org.finos.symphony.toolkit.workflow.fixture.TestObjects) TestObject(org.finos.symphony.toolkit.workflow.fixture.TestObject) EJTestObject(org.finos.symphony.toolkit.workflow.fixture.EJTestObject) BigDecimal(java.math.BigDecimal) Test(org.junit.jupiter.api.Test)

Example 4 with TestObjects

use of org.finos.symphony.toolkit.workflow.fixture.TestObjects in project spring-bot by finos.

the class TestFormConverter method testFormContainingList.

@SuppressWarnings("unchecked")
@Test
public void testFormContainingList() throws Exception {
    Object o = om.readValue("{\"action\":\"add+0\",\"items.[0].isin.\":\"fd3442\",\"items.[0].bidAxed.\":\"true\",\"items.[0].askAxed.\":\"true\",\"items.[0].creator.\":\"tr\",\"items.[0].bidQty.\":\"32432\",\"items.[0].askQty.\":\"234\"}", Map.class);
    TestObjects to = (TestObjects) fc.convert((Map<String, Object>) o, TestObjects.class.getCanonicalName());
    Assertions.assertEquals("fd3442", to.getItems().get(0).getIsin());
    Assertions.assertEquals("tr", to.getItems().get(0).getCreator());
    Assertions.assertEquals(32432, to.getItems().get(0).getBidQty());
}
Also used : TestObjects(org.finos.symphony.toolkit.workflow.fixture.TestObjects) TestObject(org.finos.symphony.toolkit.workflow.fixture.TestObject) WeirdObject(org.finos.symphony.toolkit.workflow.fixture.WeirdObject) Map(java.util.Map) Test(org.junit.jupiter.api.Test)

Example 5 with TestObjects

use of org.finos.symphony.toolkit.workflow.fixture.TestObjects in project spring-bot by finos.

the class TestHistory method testFindInHistory.

@Test
public void testFindInHistory() {
    TestObjects one = new TestObjects();
    TestObjects two = new TestObjects();
    TestObjects three = new TestObjects();
    Mockito.when(messagesApi.v1MessageSearchPost(Mockito.any(), Mockito.isNull(), Mockito.isNull(), Mockito.anyInt(), Mockito.anyInt(), Mockito.any(), Mockito.any())).thenAnswer(a -> {
        V4MessageList out = new V4MessageList();
        out.addAll(Arrays.asList(makeMessage(one), makeMessage(two), makeMessage(three)));
        return out;
    });
    List<TestObjects> out = mh.getFromHistory(TestObjects.class, new SymphonyRoom("someroom", "abc123"), Instant.now().minus(10, ChronoUnit.DAYS));
    Assertions.assertEquals(3, out.size());
    Assertions.assertEquals(one, out.get(0));
    Assertions.assertEquals(two, out.get(1));
    Assertions.assertEquals(three, out.get(2));
    Mockito.verify(messagesApi).v1MessageSearchPost(Mockito.argThat(e -> {
        MessageSearchQuery msq = (MessageSearchQuery) e;
        return msq.getHashtag().equals(TestObjects.class.getCanonicalName().replace(".", "-").toLowerCase());
    }), Mockito.isNull(), Mockito.isNull(), Mockito.eq(0), Mockito.eq(50), Mockito.isNull(), Mockito.isNull());
}
Also used : Arrays(java.util.Arrays) TestObjects(org.finos.symphony.toolkit.workflow.fixture.TestObjects) SymphonyHistory(org.finos.symphony.toolkit.workflow.sources.symphony.history.SymphonyHistory) Autowired(org.springframework.beans.factory.annotation.Autowired) Instant(java.time.Instant) V4MessageList(com.symphony.api.model.V4MessageList) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) List(java.util.List) ChronoUnit(java.time.temporal.ChronoUnit) V4Message(com.symphony.api.model.V4Message) EntityJson(org.finos.symphony.toolkit.json.EntityJson) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) Assertions(org.junit.jupiter.api.Assertions) EntityJsonConverter(org.finos.symphony.toolkit.workflow.sources.symphony.json.EntityJsonConverter) MessageSearchQuery(com.symphony.api.model.MessageSearchQuery) V4MessageList(com.symphony.api.model.V4MessageList) TestObjects(org.finos.symphony.toolkit.workflow.fixture.TestObjects) MessageSearchQuery(com.symphony.api.model.MessageSearchQuery) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) Test(org.junit.jupiter.api.Test)

Aggregations

TestObjects (org.finos.symphony.toolkit.workflow.fixture.TestObjects)5 Test (org.junit.jupiter.api.Test)4 TestObject (org.finos.symphony.toolkit.workflow.fixture.TestObject)3 V4MessageList (com.symphony.api.model.V4MessageList)2 BigDecimal (java.math.BigDecimal)2 SymphonyRoom (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)2 MessageSearchQuery (com.symphony.api.model.MessageSearchQuery)1 V4Message (com.symphony.api.model.V4Message)1 Instant (java.time.Instant)1 ChronoUnit (java.time.temporal.ChronoUnit)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 EntityJson (org.finos.symphony.toolkit.json.EntityJson)1 EJTestObject (org.finos.symphony.toolkit.workflow.fixture.EJTestObject)1 WeirdObject (org.finos.symphony.toolkit.workflow.fixture.WeirdObject)1 WorkResponse (org.finos.symphony.toolkit.workflow.response.WorkResponse)1 SymphonyHistory (org.finos.symphony.toolkit.workflow.sources.symphony.history.SymphonyHistory)1 EntityJsonConverter (org.finos.symphony.toolkit.workflow.sources.symphony.json.EntityJsonConverter)1 Assertions (org.junit.jupiter.api.Assertions)1