Package com.streamreduce.core.model

Examples of com.streamreduce.core.model.Event$Builder


        SecurityService mockSecurityService = mock(SecurityService.class);
        when(mockSecurityService.getCurrentUser()).thenThrow(new AuthenticationException());
        ReflectionTestUtils.setField(eventService, "securityService", mockSecurityService);


        Event event = eventService.createEvent(EventId.READ, testUser, null);
        Assert.assertNull(event);
    }
View Full Code Here


                .user(testUser)
                .authType(AuthType.USERNAME_PASSWORD)
                .credentials(new ConnectionCredentials("somegithubusername", "somegithubpassword"))
                .build();

        Event event = eventService.createEvent(EventId.CREATE, connection, null);

        Assert.assertNotNull(event);
    }
View Full Code Here

    public void testCreateEvent_CreateEventWithLoggedInUser() throws Exception {
        // Test creating an event as a logged in user
        // (We have to mock a few things since logging a user in programmatically isn't an option)
        EventService esMock = getEventServiceMock();

        Event event = esMock.createEvent(EventId.CREATE_GLOBAL_MESSAGE, null, null);

        verifyEvent(event, EventId.CREATE_GLOBAL_MESSAGE, testUser, testAccount, null, null);
    }
View Full Code Here

    }


    private void sendInsightMessage(long sampleTime) {
        // Send one insight message for the 4th message
        Event event = new Event();
        Map<String, Object> metadata = Maps.newHashMap();
        metadata.put("targetType", "feed");
        metadata.put("targetProviderId", "rss");
        metadata.put("name", "someMetric");
        metadata.put("timestamp", sampleTime);
        event.setAccountId(testUser.getAccount().getId());
        event.setMetadata(metadata);
        event.setEventId(EventId.NODEBELLY_SUMMARY);
        messageService.sendNodebellyInsightMessage(event, sampleTime, Sets.newHashSet("#foo"));
    }
View Full Code Here

        messageService.sendNodebellyInsightMessage(event, sampleTime, Sets.newHashSet("#foo"));
    }

    private void sendUserMessage(long sampleTime) throws Exception {
        // Send one insight message for the 4th message
        Event event = new Event();
        Map<String, Object> metadata = Maps.newHashMap();
        metadata.put("targetType", "when_can_we_have_elastic_search_please?");
        metadata.put("targetProviderId", "when_can_we_have_elastic_search_please?");
        metadata.put("name", "when_can_we_have_elastic_search_please?");
        metadata.put("timestamp", sampleTime);
        event.setAccountId(testUser.getAccount().getId());
        event.setMetadata(metadata);
        event.setEventId(EventId.NODEBELLY_SUMMARY);
        messageService.sendUserMessage(event, testUser, "All praise be to Shay Banon");
    }
View Full Code Here

        Map<String, Object> eventContext = new HashMap<>();

        eventContext.put("message", message);
        eventContext.put("payload", json);

        Event event = applicationManager.getEventService().createEvent(EventId.USER_MESSAGE, null, eventContext);

        try {
            sobaMessage = applicationManager.getMessageService().sendUserMessage(event, sender, message);
        } catch (TargetNotFoundException e) {
            return error(e.getMessage(), Response.status(Response.Status.BAD_REQUEST));
View Full Code Here

        map.put("type", mtype);
       
        map.put("targetConnectionAlias", "ParentConnectionName");
        map.put("targetAlias", "ParentInventoryName");
 
        Event event = new Event();
        event.setEventId(EventId.valueOf((String) map.get("type")));
        event.setTargetId((ObjectId) map.get("targetId"));
        event.setMetadata(map);

        NodebellyMessageTransformer transformer = setupTransformer();
        String output = transformer.doTransform(event);
        assertTrue(output != null);
        //System.out.println(output);
View Full Code Here

        try {
            // just the basics to construct NB messages
            // we may add more info as needed in the MessageService
            // but avoid lookups here for now since soon this will just be a queue and not send messages.
            Event event = new Event();

            // TODO: This should be rewritten to use EventService#createEvent(...) and to have a real EventId

            if (!account.equals("global")) {
                event.setAccountId(new ObjectId(account));
            }
            event.setEventId(EventId.valueOf((String) eventMap.get("type")));

            //If this came from AMQ it may be be a serialized ObjectId, or if it
            //came from elsewhere it's a string representation of ObjectId.  Instantiate
            //a new ObjectId just in case.
            event.setTargetId(new ObjectId(eventMap.get("targetId").toString()));
            event.setMetadata(eventMap);

            messageService.sendNodebellyInsightMessage(event, (Long) eventMap.get("timestamp"), null);
        } catch (Exception e) {
            logger.error("Failed to send a NodebellyInsightMessage:  " + e.getMessage(), e);
        }
View Full Code Here

    public void testDeletedTransform() throws Exception {
        testDoTransform(EventId.DELETE, "@sourceAlias has deleted a targetProviderDisplayName connection: targetAlias");
    }

    private void testDoTransform(EventId eventId, String expected) throws Exception {
        Event event = new Event.Builder().eventId(eventId).context(metadata).build();
        ConnectionMessageTransformer transformer = new ConnectionMessageTransformer(properties, null);
        Assert.assertEquals(expected, transformer.doTransform(event));
    }
View Full Code Here

        // Persist the inventory item
        inventoryItemDAO.save(inventoryItem);

        // Create the event
        Event event = eventService.createEvent(EventId.CREATE, inventoryItem, null);

        // Create the message
        messageService.sendInventoryMessage(event, inventoryItem);

        return inventoryItem;
View Full Code Here

TOP

Related Classes of com.streamreduce.core.model.Event$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.