How to Create a Facebook App with Java RED HAT DEVELOPER DAY Introduction Craig Schwarzwald Author / Contributor: OCPsoft.org RED HAT DEVELOPER DAY Agenda What's in store: Create an app from scratch ● Host it on the cloud ● Add Facebook functionality ● Make it into a game ● Use Integration tests for our test strategy ● RED HAT DEVELOPER DAY What we believe Simpler is better. RED HAT DEVELOPER DAY Complexity and Fragmentation Facebook APIs and SDKs: JavaScript PHP IOS Android Graph API Depricated/Replaced SDKs and APIs: Python SDK C# SDK Facebook iPhone SDK Old REST API I just want a way to get started. Red Hat opensource tools: OpenShift – free cloud hosting Hibernate – Easy access to store/retrieve data Arquillian – Automated Integration tests. Forge – Keeping everything simple! RED HAT DEVELOPER DAY Live Demo RED HAT DEVELOPER DAY The Demo App Useful Facebook app strategies ● Use minimal JavaScript, just to make Facebook API calls. ● Have a WebService which contains all our business logic. Pass information to/from our UI and to/from our Database via http GET and POST calls. ● Use automated Integration tests to make sure our entire app works correctly. ● RED HAT DEVELOPER DAY Installing Javascript SDK FB API call for MyInfo FB API call for FriendsInfo Verify functionality on Facebook RED HAT DEVELOPER DAY Quick update to Entities Create our WebService functionality Verify WebService is set up RED HAT DEVELOPER DAY WebService – Create a Player RED HAT DEVELOPER DAY Call WebService from JavaScript RED HAT DEVELOPER DAY Call WebService from JavaScript RED HAT DEVELOPER DAY Let’s create our game RED HAT DEVELOPER DAY Creating the random Game link - 1 Creating the random Game link - 2 Add the Game Link to Player RED HAT DEVELOPER DAY WebService to process answers Submit Answers from JavaScript RED HAT DEVELOPER DAY View the game on Facebook RED HAT DEVELOPER DAY What's needed in testing? Tests should live within the code. ● Tests need to be fast! ● Tests should not rely on mocks! ● Tests should be query and assert against your application’s APIs. ● RED HAT DEVELOPER DAY Testing Solution RED HAT DEVELOPER DAY Forge Arquillian Plugin RED HAT DEVELOPER DAY First Sample Test In Container Test UtilClass @Before and @After Tests - 1 RED HAT DEVELOPER DAY @Before and @After Tests - 2 @Before and @After Tests - 3 @Before and @After Tests - 4 End-To-End with No Mocks! - 1 End-To-End with No Mocks! - 2 Conclusion What we've accomplished: Created an app on the Facebook Domain ● Hosted for free on OpenShift ● Created a WebService with all our logic ● Implemented Arquillian Tests to ensure correct behavior ● RED HAT DEVELOPER DAY What's Next? Next Steps: ● Continue Arquillian tests for boundary conditions Set up a MySQL Database using OpenShift with 1 command and changing just 5 lines of code ● RED HAT DEVELOPER DAY Visit OCPsoft.org Get the entire tutorial of this live demo including the next steps and more at OCPsoft.org under Tutorials → Facebook Follow me on Twitter @CavemanCraig The Demo Code is available at https://github.com/CavemanCraig/FBTutorialDemo
© Copyright 2024