Skip to content

kc-timbrier/acebook-java-template

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Acebook

This is a java/springboot project to be developed on. There's a video tour of the application here but you should read through these docs first.

The application uses:

  • maven to build the project
  • thymeleaf for templating
  • flyway to manage postgres db migrations
  • selenium for feature testing
  • faker to generate fake names for testing
  • junit5 for unit testing
  • assertj for assertions in tests
  • mockito for mocking in unit tests
  • spring-security for authentication and user management

Below, you'll find specific learning objectives for each tool.

QuickStart Instructions

  • Fork and clone this repository to your machine
  • Open the codebase in an IDE like InteliJ or VSCode
  • Create a new Postgres database called acebook_springboot_development
  • Make sure you have Maven installed brew install maven
  • Build the app and start the server, using the Maven command mvn spring-boot:run

The database migrations will run automatically at this point

  • Visit http://localhost:8080/users/new to sign up

Running the tests

Existing features

This app already has a few basic features

  • A user can sign up at /users/new
  • A signed up user can sign in at /login
  • A signed in user can create posts at /posts
  • A signed in user can sign out at /logout

Design

This app uses a structure that is similar to Bookmark Manager. The biggest difference is that, here, the repository pattern is used. The repository pattern separates the business logic of models from the responsibility of connecting to the database and making queries. Take a look in the src/main/java/repository and you'll find PostRepository which generates and executes queries to Create, Read, Update and Delete (CRUD) posts.

Initial learning goals

You don't need an in-depth knowledge of each dependency listed above. Once you can tick off these learning goals, you're ready to dive in. It's assumed that you can already TDD the Takeaway Challenge, or something of similar complexity, in Java. It's OK if you need to pause here with Acebook and learn how to do that now :)

Maven

  • I can explain what pom.xml is for
  • I can start the app using Maven

Thymeleaf

  • I can explain the code in posts/index.html
  • I can plan a new template that could be used for editing a post

Flyway

  • I can explain what a migration is
  • I can explain when migrations are run
  • I can explain the code in the two migration files in this directory /db/migration/
  • I can explain the naming convention for flyway migration files

Selenium

  • I can explain the code in SignUpTest.java
  • I can write a new feature test for unsuccessful sign up

Faker

  • I can explain what Faker does
  • I can explain why it's useful

JUnit5

  • I can explain the code in PostTest.java
  • I could add more test cases to PostTest.java

Mockito

  • I can explain what the call to verify does in the savesProvidedPost method in PostsControllerTest.java
  • I can explain what the call to when does in the populatesPostsObjectFromThePostRepository method in PostsControllerTest.java
  • I can explain why an ArgumentCaptor is used in the savesAuthorityWithUsersNameAndCorrectRole method in UsersControllerTest.java
  • I can explain why mocking can be useful in tests

The repository pattern

  • I can explain the repository pattern

SpringBoot

  • I can diagram how this SpringBoot application handles GET "/posts"

Spring Security

  • I can explain how this app is secured

Possible extensions

Here are a few examples of new features which could be added to Acebook. Feel free to implement as many as you wish, or if you have your own ideas try them out.

  • Add a logout button to the /posts page
  • Include username on posts
  • Include timestamp on posts
  • Allow a user to add friends, and only show posts from a users friends
  • Allow a user to delete posts

Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 89.6%
  • HTML 9.4%
  • CSS 1.0%