private void sendMessage(JsonObject msg) { EventLog.addEvent("Sending message: " + msg.encode()); try { vertx.eventBus().publish(TestBase.EVENTS_ADDRESS, msg); } catch (Exception e) { log.error("Failed to send message", e); } }
/** * Logs the event message to the output stream. * * @param out Stream to which the message is logged. * @param event Message to be logged. */ private void log(PrintStream out, String event) { if (null == log) { out.println(event); out.flush(); } else { log.log(event); } }
/** * Compares the sum of all travel times with the sum of all travel times generated by the * C++DEQSim. As {@link #compareToDEQSimEvents(String)} does not function for most comparisons of * the JavaDEQSim and C++DEQSim model, we need to compare the time each car was on the road and * take its average. This figure should with in a small interval for both simulations. Attention: * Still when vehicles are stuck, this comparison can be off by larger number, because unstucking * the vehicles is done in different ways by the two simulations */ protected void compareToDEQSimTravelTimes( final String deqsimEventsFile, final double tolerancePercentValue) { ArrayList<EventLog> deqSimLog = CppEventFileParser.parseFile(deqsimEventsFile); double deqSimTravelSum = EventLog.getSumTravelTime(deqSimLog); double javaSimTravelSum = EventLibrary.getSumTravelTime(allEvents); assertTrue( (Math.abs(deqSimTravelSum - javaSimTravelSum) / deqSimTravelSum) < tolerancePercentValue); }
public void testSerialize() { String s = "aced0005737200206a6176612e6265616e732e50726f70657274794368616e67" + "65537570706f727458d5d264574860bb03000349002a70726f706572747943686" + "16e6765537570706f727453657269616c697a65644461746156657273696f6e4c" + "00086368696c6472656e7400154c6a6176612f7574696c2f486173687461626c6" + "53b4c0006736f757263657400124c6a6176612f6c616e672f4f626a6563743b78" + "7000000002737200136a6176612e7574696c2e486173687461626c6513bb0f252" + "14ae4b803000246000a6c6f6164466163746f724900097468726573686f6c6478" + "703f4000000000000877080000000b00000001740001617371007e00000000000" + "2707400046265616e7372003a6c6962636f72652e6a6176612e7574696c2e6265" + "616e732e50726f70657274794368616e6765537570706f7274546573742445766" + "56e744c6f67b92667637d0b6f450200024c00036c6f677400104c6a6176612f75" + "74696c2f4c6973743b4c00046e616d657400124c6a6176612f6c616e672f53747" + "2696e673b7870737200136a6176612e7574696c2e41727261794c6973747881d2" + "1d99c7619d03000149000473697a6578700000000077040000000a7874000b6c6" + "97374656e6572546f4171007e000c70787871007e00087371007e00097371007e" + "000d0000000077040000000a7874000d6c697374656e6572546f416c6c7078"; Object bean = "bean"; PropertyChangeSupport support = new PropertyChangeSupport(bean); EventLog listenerToAll = new EventLog(); listenerToAll.name = "listenerToAll"; EventLog listenerToA = new EventLog(); listenerToA.name = "listenerToA"; support.addPropertyChangeListener(listenerToAll); support.addPropertyChangeListener("a", listenerToA); support.addPropertyChangeListener("a", listenerToA); new SerializationTester<PropertyChangeSupport>(support, s) { @Override protected boolean equals(PropertyChangeSupport a, PropertyChangeSupport b) { return describe(a.getPropertyChangeListeners()) .equals(describe(b.getPropertyChangeListeners())); } @Override protected void verify(PropertyChangeSupport deserialized) { assertEquals( "[a to listenerToA, a to listenerToA, listenerToAll]", describe(deserialized.getPropertyChangeListeners())); } }.test(); }
@Override public void msgHereIsVerifiedKit(Kit kit) { log.add( new LoggedEvent( "Received msgHereIsVerifiedKit from kit robot " + "that kit: " + kit.name + " is ready to be put " + "on the conveyor.")); }
@Override public void eventFired(TChannel channel, TEvent event, Object[] args) { log.add( new LoggedEvent( "Event fired on channel " + channel.toString() + ". Event is " + event.toString() + " with parameters " + args.toString())); }
public void msgYouHaveDebt(double remaining_cost) { log.add(new LoggedEvent("Received YouOweUs from cashier. Debt = " + remaining_cost)); System.out.printf(getName() + ": Recieved $%.2f of debt from cashier.%n", remaining_cost); }
public void msgHereIsYourChange(double change) { log.add(new LoggedEvent("Received HereIsYourChange from cashier. Change = " + change)); System.out.printf(getName() + ": Recieved $%.2f in change from cashier.%n", change); }
public void msgHereIsYourCheck(double total) { log.add(new LoggedEvent("Received msgHereIsCheck from waiter. Total = " + total)); System.out.printf(getName() + ": Recieved $%.2f bill from waiter.%n", total); }
@RequestMapping(value = path + "details") @ResponseBody public Request viewVoteDetails( @RequestParam(value = phoneNumber) String inputNumber, @RequestParam(value = entityUidParam) String eventUid, @RequestParam(value = "back") String backMenu) throws URISyntaxException { // todo: decide whether to allow users to change the closing time (& permissions, of course) // todo: have some way of counting reminders and only allow once unless paid account // todo: reconsider whether to save URL here, might want to set back to null User user = userManager.findByInputNumber( inputNumber, saveVoteMenu("details", eventUid) + "&back=" + backMenu); Event vote = eventBroker.load(eventUid); boolean futureEvent = vote.getEventStartDateTime().isAfter(Instant.now()); ResponseTotalsDTO voteResults = eventLogBroker.getResponseCountForEvent(vote); USSDMenu menu; if (futureEvent) { EventLog userResponse = eventLogRepository.findByEventAndUserAndEventLogType(vote, user, EventLogType.RSVP); String responseText; List<String> otherResponses; if (userResponse == null || !userResponse.hasValidResponse()) { responseText = "not voted yet"; otherResponses = Arrays.asList("yes", "no", "abstain"); } else { switch (userResponse.getResponse()) { case YES: responseText = "yes"; otherResponses = Arrays.asList("no", "abstain"); break; case NO: responseText = "no"; otherResponses = Arrays.asList("yes", "abstain"); break; case MAYBE: responseText = "abstain"; otherResponses = Arrays.asList("yes", "no"); break; default: responseText = "not voted yet"; otherResponses = Arrays.asList("yes", "no", "abstain"); break; } } final String suffix = entityUidUrlSuffix + eventUid; final String[] fields = new String[] { vote.getAncestorGroup().getName(""), vote.getName(), "" + (voteResults.getNumberOfUsers() - voteResults.getNumberNoRSVP()), responseText }; menu = new USSDMenu(getMessage(thisSection, "details", "future." + promptKey, fields, user)); for (String voteOption : otherResponses) { menu.addMenuOption( voteMenus + "change-vote" + suffix + "&response=" + voteOption, getMessage(thisSection, "details", optionsKey + "change", voteOption, user)); } } else { String[] fields = new String[] { vote.getAncestorGroup().getName(""), vote.getName(), "" + voteResults.getYes(), "" + voteResults.getNo(), "" + voteResults.getMaybe(), "" + voteResults.getNumberNoRSVP() }; menu = new USSDMenu(getMessage(thisSection, "details", promptKey, fields, user)); } menu.addMenuOption( voteMenus + backMenu, getMessage(thisSection, "details", optionsKey + "back", user)); return menuBuilder(menu); }
void doPrintNotification(final Notification notification) { Editor editor = myLogEditor.getValue(); if (editor.isDisposed()) { return; } Document document = editor.getDocument(); boolean scroll = document.getTextLength() == editor.getCaretModel().getOffset() || !editor.getContentComponent().hasFocus(); Long notificationTime = myProjectModel.getNotificationTime(notification); if (notificationTime == null) { return; } String date = DateFormatUtil.formatTimeWithSeconds(notificationTime) + " "; append(document, date); int startLine = document.getLineCount() - 1; EventLog.LogEntry pair = EventLog.formatForLog(notification, StringUtil.repeatSymbol(' ', date.length())); final NotificationType type = notification.getType(); TextAttributesKey key = type == NotificationType.ERROR ? ConsoleViewContentType.LOG_ERROR_OUTPUT_KEY : type == NotificationType.INFORMATION ? ConsoleViewContentType.NORMAL_OUTPUT_KEY : ConsoleViewContentType.LOG_WARNING_OUTPUT_KEY; int msgStart = document.getTextLength(); String message = pair.message; append(document, message); TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key); int layer = HighlighterLayer.CARET_ROW + 1; editor .getMarkupModel() .addRangeHighlighter( msgStart, document.getTextLength(), layer, attributes, HighlighterTargetArea.EXACT_RANGE); for (Pair<TextRange, HyperlinkInfo> link : pair.links) { myHyperlinkSupport .getValue() .addHyperlink( link.first.getStartOffset() + msgStart, link.first.getEndOffset() + msgStart, null, link.second); } append(document, "\n"); if (scroll) { editor.getCaretModel().moveToOffset(document.getTextLength()); editor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE); } if (notification.isImportant()) { highlightNotification(notification, pair.status, startLine, document.getLineCount() - 1); } }
@Override public void msgIAmFree() { log.add(new LoggedEvent("Received message msgIAmFree")); }
@Override public void msgHereIsGlass(Glass glass) { log.add(new LoggedEvent("Received message msgHereIsGlass")); }
@Override public void msgNeedEmptyKit() { log.add(new LoggedEvent("Received msgNeedEmptyKit from kit robot.")); }
public void msgHereIsPayment(int amount) { log.add(new LoggedEvent("Received message msgHereIsPayment from cashier")); }