Giter VIP home page Giter VIP logo

playground-junit's Introduction

Playground-junit

The purpose of this repository is to have a common space in order to practice Springboot, Java and JUnit. Java version is 1.8

Colours

This package contains an Enum class, Colour, which contains rainbow colours. The purpose of Colour is to represent a basic list of values, indexes, i.e. with a default order.
In addition to this list, if we're given another random, dynamic list of values, we will show that we can render the basic list on top, ordered by index ascending, following by the random list, sorted by name and also assigning an index (idempotent, guaranteed to be the same every time for the same value, case insensitive).

E.g. for the list of rainbow colours: [RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET] with indexes: [0, ..., 6], if we're given the following list: [PURPLE, PINK, BLACK], then the final list will be:
[RED, ORANGE, YELLOW, GREEN, BLUE, INDIGO, VIOLET, BLACK, PINK, PURPLE] with indexes: [0, ..., 7, 8, 9]

The last random colours are sorted by name in ascending order and given an increasing index, starting from the last index of the last rainbow colour. The next time another list is given, the non-rainbow colours will be re-arranged in ascending order, just like the aforementioned example.

This example can be a use case for a hardware store where we sell some popular paint colours and less popular ones or ones in high stock.

Another use case scenario can be applied on a medical website listing popular/basic diseases always on top with a fixed order always, while i.e. every month populating some other, less popular, diseases at the bottom of the page. For that, we would need to have a sorting mechanism (for us, it's enough to sort by name, but this can easily change, depending on the second parameter - comparing function - in the toSorted method).

Package colours contains:

  • Colour class is the enum with basic methods for ordering by name or index.
  • Utils class contains helper methods.
  • ColourTest class has unit tests written in Junit5 using junit-jupiter-params library, for data driven tests (parameterized tests).

playground-junit's People

Contributors

mariamichou avatar

Watchers

James Cloos avatar  avatar

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.