@Test public void welcomeMessageTest() { when(connectionConfig.username()).thenReturn("bob"); when(connectionConfig.driverUrl()).thenReturn("bolt: UserMessagesHandler userMessagesHandler = new UserMessagesHandler(connectionConfig, "3.1.0-Beta99"); assertEquals("Connected to Neo4j 3.1.0-Beta99 at @|BOLD bolt: "Type @|BOLD :help|@ for a list of available commands or @|BOLD :exit|@ to exit the shell.\n" + "Note that Cypher queries must end with a @|BOLD semicolon.|@", userMessagesHandler.getWelcomeMessage()); }
@Nonnull public String getWelcomeMessage() { String neo4j = "Neo4j"; if (!serverVersion.isEmpty()) { neo4j += " " + serverVersion; } AnsiFormattedText welcomeMessage = AnsiFormattedText.from("Connected to ") .append(neo4j) .append(" at ") .bold().append(connectionConfig.driverUrl()).boldOff(); if (!connectionConfig.username().isEmpty()) { welcomeMessage = welcomeMessage .append(" as user ") .bold().append(connectionConfig.username()).boldOff(); } return welcomeMessage .append(".\nType ") .bold().append(Help.COMMAND_NAME).boldOff() .append(" for a list of available commands or ") .bold().append(Exit.COMMAND_NAME).boldOff() .append(" to exit the shell.") .append("\nNote that Cypher queries must end with a ") .bold().append("semicolon.").boldOff().formattedString(); }
UserMessagesHandler { @Nonnull public String getWelcomeMessage() { String neo4j = "Neo4j"; if (!serverVersion.isEmpty()) { neo4j += " " + serverVersion; } AnsiFormattedText welcomeMessage = AnsiFormattedText.from("Connected to ") .append(neo4j) .append(" at ") .bold().append(connectionConfig.driverUrl()).boldOff(); if (!connectionConfig.username().isEmpty()) { welcomeMessage = welcomeMessage .append(" as user ") .bold().append(connectionConfig.username()).boldOff(); } return welcomeMessage .append(".\nType ") .bold().append(Help.COMMAND_NAME).boldOff() .append(" for a list of available commands or ") .bold().append(Exit.COMMAND_NAME).boldOff() .append(" to exit the shell.") .append("\nNote that Cypher queries must end with a ") .bold().append("semicolon.").boldOff().formattedString(); } }
UserMessagesHandler { @Nonnull public String getWelcomeMessage() { String neo4j = "Neo4j"; if (!serverVersion.isEmpty()) { neo4j += " " + serverVersion; } AnsiFormattedText welcomeMessage = AnsiFormattedText.from("Connected to ") .append(neo4j) .append(" at ") .bold().append(connectionConfig.driverUrl()).boldOff(); if (!connectionConfig.username().isEmpty()) { welcomeMessage = welcomeMessage .append(" as user ") .bold().append(connectionConfig.username()).boldOff(); } return welcomeMessage .append(".\nType ") .bold().append(Help.COMMAND_NAME).boldOff() .append(" for a list of available commands or ") .bold().append(Exit.COMMAND_NAME).boldOff() .append(" to exit the shell.") .append("\nNote that Cypher queries must end with a ") .bold().append("semicolon.").boldOff().formattedString(); } UserMessagesHandler(@Nonnull ConnectionConfig connectionConfig, @Nonnull String serverVersion); }
UserMessagesHandler { @Nonnull public String getWelcomeMessage() { String neo4j = "Neo4j"; if (!serverVersion.isEmpty()) { neo4j += " " + serverVersion; } AnsiFormattedText welcomeMessage = AnsiFormattedText.from("Connected to ") .append(neo4j) .append(" at ") .bold().append(connectionConfig.driverUrl()).boldOff(); if (!connectionConfig.username().isEmpty()) { welcomeMessage = welcomeMessage .append(" as user ") .bold().append(connectionConfig.username()).boldOff(); } return welcomeMessage .append(".\nType ") .bold().append(Help.COMMAND_NAME).boldOff() .append(" for a list of available commands or ") .bold().append(Exit.COMMAND_NAME).boldOff() .append(" to exit the shell.") .append("\nNote that Cypher queries must end with a ") .bold().append("semicolon.").boldOff().formattedString(); } UserMessagesHandler(@Nonnull ConnectionConfig connectionConfig, @Nonnull String serverVersion); @Nonnull String getWelcomeMessage(); @Nonnull String getExitMessage(); }
UserMessagesHandler { @Nonnull public String getWelcomeMessage() { String neo4j = "Neo4j"; if (!serverVersion.isEmpty()) { neo4j += " " + serverVersion; } AnsiFormattedText welcomeMessage = AnsiFormattedText.from("Connected to ") .append(neo4j) .append(" at ") .bold().append(connectionConfig.driverUrl()).boldOff(); if (!connectionConfig.username().isEmpty()) { welcomeMessage = welcomeMessage .append(" as user ") .bold().append(connectionConfig.username()).boldOff(); } return welcomeMessage .append(".\nType ") .bold().append(Help.COMMAND_NAME).boldOff() .append(" for a list of available commands or ") .bold().append(Exit.COMMAND_NAME).boldOff() .append(" to exit the shell.") .append("\nNote that Cypher queries must end with a ") .bold().append("semicolon.").boldOff().formattedString(); } UserMessagesHandler(@Nonnull ConnectionConfig connectionConfig, @Nonnull String serverVersion); @Nonnull String getWelcomeMessage(); @Nonnull String getExitMessage();  }