Giter Club home page Giter Club logo

sea-chuck-bot's People

Contributors

armanmsb avatar corinnalovesbaileys avatar djcd avatar eldorwildcodeschool avatar ice09 avatar leanderkl avatar riethigsea avatar sea-w6-mf avatar sea-w6-rr avatar sup3rwoman avatar wildermoschool avatar

Watchers

 avatar  avatar

sea-chuck-bot's Issues

As a developer, I can use an unified API for Joke persistence.

Description

Currently, the import and storage of jokes is implemented in multiple classes and without an interface/API. For other developers to be able to use the persistence of jokes, the API should be like this:

Interface Specification

  • JokesPersistence is an interface which specifies
    • List<Joke> loadData() and storeData(List<Joke> jokes)
    • One implementation of the interface: JokesFilePersistence which provides a constructor JokesFilePersistence(File storage) and implements the methods for files.
  • Importing of a file should be possible by setting a CLI arg import FILENAME
  • After import the imported data should be printed

Acceptance Criteria

  • The main method has a handling for CLI arg import FILENAME which imports jokes and prints them.
  • The implementation uses interface and file implementation JokesPersistence jokesPersistence = new JokesFilePersistence(args[1])

Dependencies

  • There is a dependency on the refactoring of the Joke data structure.

Tests

  • loadDataImportJokes(): checks, if the program can import the jokes correctly from a file
  • loadDataFileExtension(): checks, if the Jokes File has the correct file extension
  • loadDataEmptyLines(): checks, if the program reacts correctly to empty lines in Jokes file
  • loadDataFileExists(): checks, if the program reacts correctly, if the Joke file does not exists
  • loadDataClearFile(): checks, if the program reacts correctly, if the Joke file is empty
  • loadDataWrongDateFormat(): checks, if the program reacts correctly, if the Joke file contains invalid date patterns
  • loadDataSeparator(): checks, if the program reacts correctly, if the Separator in Joke file is contained several times
  • storeData(): checks, if the program stores the Jokes correctly in Joke file
  • storeDataFileNotExist(): checks, if the program reacts correctly, if the method storeData wants to write in a Joke file, which does not exist
  • cleanUp(): Cleans up after all tests (deletes new created files during test routine)

Deliverables

As a user, I can see a sorted list for newest jokes.

Description

As a user, I don't want to see the oldest jokes, but always the newest ones first. There should be a method which sorts Jokes for their creationDate descending.

Acceptance Criteria

  • The main method has a handling for CLI arg display_sorted FILENAME which imports jokes and prints them for their creationDate descending.

Dependencies

  • There is a dependency on the refactoring of the Joke data structure.
  • There is a dependency on the new interface for Joke persistence.

Tests

Deliverables

Create REST Test Suite for Chuck-Bot

Description

Create a Test Suite which can be started manually and executes all tests automatically. Use either IntelliJ, VSCode or Postman. The tests should simulate a complete flow: retrieving jokes, creating a new joke, retrieving again, delete, retrieving again.

Acceptance Criteria

  • The flow should be testable: Read all jokes and store state (store number), Create new Joke, Read all jokes (check number+1), Delete joke, Read again (check number)

Prepare Demo Environment

Description

Prepare Demo (Environment)

  • Presentation/Overview of Technologies
  • Prepare Demo story & steps
  • Who will present which topic?

As a developer, I want to use a Mock for the real RocketChat-Bot.

Description

To be able to test the application without a running external service, a mocked chatbot is necessary. This mocked bot should read from the database and be configurable for the tags to listen for.

The mocked bot will simulate a Chat Bot by reading commands from System.in. Each command will ask a ChatBotServiceMock if an action is configured for the input and if it is, execute it.

Acceptance Criteria

  • A mocked Service is running which listens for tags and displays current jokes.

Dependencies

Tests

Deliverables

As a user, I want to see all currently stored jokes as a HTML page.

Description

To be able to see all currently stored jokes, with opening http://localhost:8080/jokes all jokes are queried from the database and display as HTML.
The jokes should either be sorted alphabetically or by date.

See https://www.baeldung.com/thymeleaf-in-spring-mvc

Acceptance Criteria

  • All currently stored jokes are displayed when the site is opened.
  • Jokes can be sorted for alphabetical order or by date.

Dependencies

Tests

Deliverables

Prepare Going-Live for Chuck-Bot-Web-Application on Heroku.

Description

The application should be deployed on Heroku, so it can be accessed from everywhere, not just on a local environment.

Necessary Steps

  • Change application persistence to Postgres.
  • How to store/change the database URL?
  • Setup deployment steps.
  • How to build/deploy on demand (on on commit).

Acceptance Criteria

  • Application Web UI can be accessed from everywhere.
  • Application can be deployed in a new state everytime.
  • REST Services are (for bot only?) openly accessible.

As a developer, I want to use the ChuckNorris Joke Engine as a Service

Description

Currently, the functionality is implemented in different classes. As a developer using the ChuckNorris Joke Engine, eg. from a Web application, I want to be able to use a unified API, like:

JokesPersistence persistence = new JokesFilePersistence(new File("jokes.txt"));
ChuckNorrisJokeService jokeService = new ChuckNorrisJokeService(persistence);

jokeService.initialize();
jokeService.printAllJokes();
jokeService.getNewestJoke();
jokeService.addNewJoke(Joke joke);
jokeService.shutdown();

Interface Specification

  • initialize(): Loads data from configured persistence.
  • printAllJokes(): Prints all imported jokes.
  • getNewestJoke(): Gets the most recently added (creationDate) Joke
  • getRandomJoke(): Gets a random Joke from the service.
  • addNewJoke(Joke joke): Adds a new Joke to the service.
  • shutdown(): Shutdown of the Service, the currently stored Jokes are persisted.

Acceptance Criteria

  • The main method should handle everything by using the new Service

Dependencies

  • There is a dependency on all other issues.

Tests

Deliverables

Migrate Database Persistence from plain JDBC to JPA.

Description

The currently implemented DB-Persistence should be migrated from the verbose plain JDBC to JPA.

Necessary Steps

  • Introduce JPA (Entities)
  • Remove all legacy Code (DBPersistence)
  • Introduce Spring and Spring Data (Repository, DI)
  • Adjust application.properties

Acceptance Criteria

  • No manual connection/statement/resultset handling anymore.
  • JPA Entities are used for persistence.
  • Spring Data mechanisms are used (Repository, DI).
  • No changes in logic.

Technical Debt: Remove unused classes

Description

Currently, there are remaining classes for iterative development, eg. JokesContainer. Check if the classes are still used and if not, delete them.
The main method should be able to handle different command line arguments. Make sure the arguments are checked (null?, size>0?) and each new call gets an own switch or if branch.

Acceptance Criteria

All classes should be used, the main method is well structured and robust.

Dependencies

  • This clean-up task is dependent on all other tasks.

Prepare Going Live for Chuck-Bot-Adapter (Node.JS).

Description

The bot-adapter, which logs in to Rocket.Chat as bot (with role bot) and listens to channel GENERAL should be running on a dedicated environment, not just locally.

Necessary Steps

  • Clarify on how to run the bot (Docker? Node.js standalone?)
  • How/where to run the bot (Docker/Node.js)?

Acceptance Criteria

  • Bot can be used in WCS Rocket.Chat, ie. logs in, listens and forwards to REST Services.

As a user, I want to use a real Rocket.Chat for jokes retrieval.

Description

The mocked Rocket.Chat should be replaced with a running version on localhost. As a first step, a locally running Rocket.Chat should be running. Next steps are creating a Bot which listens as a user of the Rocket.Chat instance. The implementation can/should be in JavaScript/CoffeeScript and delegate to a Spring Boot Web Service.

Communication Diagram

SEA_CB_CommDiag

Setup Steps

Our sample bot adapter

module.exports = (chuckbot) => {
    chuckbot.respond(/(whataboutchuck)/gi, (res) => {
                //wrap the HTTP get call as a Promise
            new Promise((resolve, reject) => 
                chuckbot.http("http://host.docker.internal:8080/api/jokes/random").get()((err, response, body) =>
                    err ? reject(err) : resolve(body)
                )
            )
    
            //reply joke
            .then(body => res.reply(body))
    })
  }

Acceptance Criteria

  • Multiple at different stages.

Dependencies

Tests

Deliverables

As a user, I can add new jokes to a file and have them reimported.

Description

As a user, I can add jokes to an existing file and reimport the jokes.

Acceptance Criteria

After reimporting the file, the new jokes are included in the jokes storage data structure.

Subtasks

  • Remove existing jokes (with check?)
  • Read new jokes from file

As a user, I can read the currently persisted jokes after system start.

Description

As a user, I can start the main method with the parameter "print" and all jokes are displayed with the introduction "These are the currently stored jokes", then the application is stopped.

Acceptance Criteria

After starting the main method and using "print" as a parameter, all currently stored jokes are printed.

Subtasks

  • Parse the arguments for "print"
  • Call printing of jokes

As a user, I can call a method to print all jokes.

Description

The user (who starts the main method) can call a method to print all currently stored jokes.

Acceptance Criteria

There is a method to print out all jokes.

Subtasks

  • Create method for printing all jokes.
  • Write unit tests in JUnit for printing jokes.

As a developer, I want to access the Jokes via a REST API.

Description

For external service, it must be possible to access the jokes via a REST API. In the first iteration, the access should be read-only.

API

  • Get random joke: GET /api/jokes/random
  • Get joke by ID: GET /api/jokes/{id}
  • Get all stored jokes: GET /api/jokes

The jokes should either be sorted alphabetically or by date.

See https://spring.io/guides/gs/rest-service/

Acceptance Criteria

  • Call of REST Service (/jokes) returns all currently stored Jokes in the persistence unit.
  • Test with VSCode or IntelliJ Plugin

Dependencies

Tests

Deliverables

As a developer, I can import jokes from files.

Description

As a developer, I can put a file with jokes (one joke one line) on the filesystem and those files can be imported.

Acceptance Criteria

If the file exists, the jokes are imported and a "import successful" or "import error" message is displayed at the end.

Subtasks

  • Parse the file
  • Store the jokes in a data structure

As a developer, I can add new jokes

Description

There should be a non-persistent list of jokes (Strings). As a developer, I can add jokes, recompile the application and the new joke has been added to the list.

Acceptance Criteria

As a developer I can edit a Java file, add a joke to an existing container (array or list), recompile and the joke is then included in the container.

Subtasks

  • Create fixed or dynamic, non-persistent container for jokes.
  • Write unit tests in JUnit for adding jokes.

As a developer, I want to use a database for persisting jokes.

Description

Currently only a file-based persistence is implemented. This does not allow for more complex data structures like User->Joke or Joke->Ratings. Therefore, the file-based persistence should be deprecated for a relational database persistence.

Overview

SEA_CB drawio

Setup MySQL

# CREATE USER AND DATABASE

CREATE USER 'chuck'@'localhost' IDENTIFIED BY 'norris';
CREATE DATABASE chuckbot;
GRANT ALL PRIVILEGES ON chuckbot.* TO 'chuck'@'localhost';
FLUSH PRIVILEGES;

# CREATE TABLE

CREATE TABLE JOKES (
    ID int NOT NULL AUTO_INCREMENT,
    JOKETEXT text NOT NULL,
    ADDED date,
    PRIMARY KEY (ID)
);

# INSERT TEST DATA

INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann Feuer mit einer Lupe machen – nachts!', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris läuft 100 Meter in einer Sekunde. Er kennt immer eine Abkürzung.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann ein Feuer entfachen, indem er zwei Eiswürfel aneinander reibt.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris wurde gestern geblitzt – beim Einparken.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Wenn man Chuck Norris fragt, wie viele Liegestütze er schafft, antwortet er: "Alle."', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann ein Fünfeck zeichnen – mit vier Strichen.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris entführt Aliens.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann Drehtüren zuknallen.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris kann Atom- von Ökostrom unterscheiden – und zwar am Geschmack.', NOW());
INSERT INTO JOKES (JOKETEXT, ADDED) VALUES ('Chuck Norris hat bis Unendlich gezählt. Zweimal.', NOW());

Acceptance Criteria

  • A new class DBPersistence implements JokePersistence and uses a local MySQL database connection.

Dependencies

Tests

Deliverables

As a user, I can see when a joke has been added.

Description

The data structure for jokes currently is a String. However, more data has to be stored for the jokes, eg. a creationDate which is a LocalDate. A new class Joke should be created which has at least a String (the joke) and a LocalDate (the creation date).

Acceptance Criteria

  • All existing usages (in development) of jokes should be refcatored for the new data structure.

Dependencies

  • There is a dependency on the import and storage of jokes.

Tests

Deliverables

Create Rights-/Rolemanagement for Joke Administration

Description

Only Users with Role "ADMIN" should be able to modify jokes. Only Users with Role "USER" can read jokes. Other Users (with no Roles) are rejected.

  • Create at least 2 roles: USER and ADMIN
  • Create at least two Users with these roles
  • ADMIN has all rights (CRD)
  • USER can only read
  • Secure the MVC Endpoints
  • Secure the REST Endpoints

Acceptance Criteria

  • All Endpoints require an authenticated User
  • Only Admins can change jokes
  • Users and Admins can read jokes
  • The View (MVC) and the REST Endpoint are secured

Polish the Chuck-Bot-Admin-UI

Description

The Admin UI should look even greater! And more consistent.

Acceptance Criteria

  • Same CSS for all subpages (Telekom-style or Chuck-Norris-style?).
  • Reorder Buttons for Adding and Sorting (sorting on table header click?)
  • Remove ID column

Cleanup Repository

Description

  • Merge or Close all open PRs
  • Delete all unnecessary branches (check local ones as well)
  • Check documentation, are all steps for setting up the system locally correct?
  • Check state of issues, close if finished

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.