A reference implementation for how to build an Angular JS application backed by a JavaEE RESTful API.
This app showcases the following features (related blog post):
- How to build layers in an Angular JS MVC stack.
- How to write tests for each layer of the Angular stack
- How to run Angular and Server-side tests during the build
- How to make the Angular stack aware of the environment it is running in.
- Use d3 to render basic charts via angular directives.
View a demo here
See here for a blog post explaining this effort.
Clone or fork the repository in your workspace under a directory we will call $POINTY_HOME
The build of the Angular plus the Java stack is done using maven. This will run unit tests and build the two war's (pointy-web and pointy-api). Once you have downloaded and installed maven, please do the following:
cd $POINTY_HOME
mvn clean install -f pointy-parent/pom.xml
followed by:
mvn clean install -f pointy-parent/pom.xml -Pall,dev
The below commands run unit tests and integration tests. This translates to Jasmine Unit tests and E2E Selenium Integration tests on the Angular stack and Spring MVC tests, Spring Transactional Tests and JUnit tests using Mockito on the Java stack.
cd $POINTY_HOME
mvn clean install -Pall,dev,alltests -f pointy-parent/pom.xml
The app can be seen in action by deploying the apps (pointy-web.war and pointy-api.war) to a jetty server running on port 9020 of localhost. The jetty server can be started by doing the following:
cd $POINTY_HOME
mvn clean install -f pointy-parent/pom.xml -Pall,alltests,dev
mvn jetty:run -Palltests,dev -f pointy-web/pom.xml
Next, fire up a browser and navigate to localhost:9020/pointy
Register, Edit, Delete or List patients.
By doing this you are interacting with an Angular app (pointy-web) in the browser and using REST calls going out to pointy-api, also, incidentally, hosted on the same server. Note, tho' that if you host pointy-api on a different server, then either a CORS solution will need to be implemented (via a CORS filter maybe), or we have to change the app to accept application/javascript instead of application/json (JSONP).
The following still need to be accomplished. Pull Requests are welcome:
- Complete E2E tests using jQuery
- Write a Spring Service level unit test
- Write a Spring Service level Integration Test
- Write a Spring Repository level unit test