-
Notifications
You must be signed in to change notification settings - Fork 2
Yekta Milesone 3 report
In the final milestone of our project, I focused on enhancing the backend functionalities and refining the user experience in our application.
Initially, I improved community interaction capabilities. This involved adding a new layer for community services, controllers, and repositories, which enabled functionalities like retrieving community details and posts associated with specific communities. Key methods implemented include getCommunityByName and getPostsOfCommunity, which can be found here and here respectively, addressing the requirements in issue #156.
Following this, I improved the user profile logic by enabling functionalities such as fetching posts created by users, posts reacted to by users, and fetching user details by ID. The implementations for these are found here and here, and were essential in resolving issue #157.
To further refine the data returned from our endpoints, I created custom response structures for posts and comments. These implementations, which involve necessary JPA query methods and model adjustments, are detailed here and here. These were developed in response to issues #158 and #159. These were complex JPA Queries as it needed to show the user-specific statistics.
Security enhancements included implementing a change password functionality, which can be found here, addressing the security needs outlined in issue #160. Additionally, I integrated an endpoint for users to upload profile pictures, improving user interaction and personalization capabilities, detailed in issue #161.
I also refactored the posts to support image uploads, enhancing the content creation experience, as documented in issue #162. Furthermore, I added functionality to retrieve bookmarked posts, improving the user's ability to manage content, which can be reviewed in issue #163 however front part couldn't finish this part so it is just an endpoint for now.
Lastly, I implemented unit tests for user and post services, ensuring robust and error-free functionalities. These tests are crucial for maintaining code quality and can be explored further in issues #164 and #165.
- Issue #158 - Enhanced Post Response: Implementation of complex JPA Queries to include like, dislike, comment counts, and bookmark information in the post response, affecting all endpoints returning post objects. Since this was including like dislike comment count and bookmark infos in the post for the User surfing in our website it was really important to implement early on. View Issue
- Issue #161 - Upload Profile Picture Endpoint: Significant for enhancing user interaction by allowing image uploads in posts, achieved by configuring PostgreSQL to accept images using @Lob annotations and hibernate configuration (auto-commit) to resolve lob error when fetching rows with image. This was again very important since the frontend is affected by images in the post and it lets User's create more colorful posts with images. It was hard to implement the image acceptance to Postgres but with some configurations and using @Lob annotations at Model level solved our problem. View Issue
- Issue #156 - Community Service Implementation: Rapid development of the community creation feature, critical for the core functionality of the app, including endpoints for community posts and user registrations to communities. Creating Communities was the core soul of our app. So Implementing this was very important and it needed to be implemented fast in order for other endpoints to continue and to be refactored. I have implemented this within 3 hours besides adding community Posts endpoint and saving Users to community when registering. View Issue
I haven't got any pull request bu this has some explanation: First of all I wrote backend only with Oguz Kagnici so we were just 2 people. On top of that when we write our parts we were writing together in a Discord Meeting. Or if we didn't write together we certainly were helding a meeting in Discord before pushing or merging our commits. This way we didn't need any pull request. On top of that some conflicts on branch management that remained from previous Milestones led us not being able to use main branch and this led me to become the supervisor of branches for deploy. So basically everyone merged or pushed their commits under my supervision to hold the integrity of the branches. At the last day I manage to resolve the issue with main branch and now it can be used again.
- {{baseURL}}/api/v1/users/:id (GET) : Gets User by providing userId to path
- {{baseURL}}/api/v1/users/:id/profile-picture (PUT) : Updates PP of User with given userId in path and updates the image with the image given in form-data body.
- {{baseURL}}/api/v1/users/:userId/change-password?password=2 (PUT) : Changes the password with given one in the query parameter of the user with given Id. If the authenticated user doesn't match this Id it won't chang ethe password.
- {{baseURL}}/api/v1/communities/:communityName (GET) : Gets Community by name by providing it to the path variable. Returns the Community Object.
- {{baseURL}}/api/v1/comments/post/:postId (GET) : Gets Comment of a Post with given Id. Return Custom CommentResponse which I mentioned earlier with statistics of authorized user.
These all returns Custom PostResponse with statistics regarding the authorized User. (If the user liked, disliked, bookmarked this Post)
- {{baseURL}}/api/v1/posts/community/:communityTeam (GET) : Gets Posts postedAt specifiec Community
- {{baseURL}}/api/v1/posts/user/:userId (GET) : Gets Posts posted by User with given Id.
- {{baseURL}}/api/v1/posts/user/:userId/bookmarked (GET) : Get Posts that are bookmarked for the User with id.
- {{baseURL}}/api/v1/posts/user/:userId/reacted (GET) : Get Posts User Reacted to
Refactored these endpoints after the second Milestone: -{{baseURL}}/api/v1/posts (POST): Creates Post with addition to add image. -{{baseURL}}/api/v1/posts/feed (GET) : Gets the feed customized to authorized User.
All of the endpoints under the url /api/v1/posts can be seen in this folder and /api/v1/users/ under this , /api/v1/communities/ under this and /api/v1/comments/ under this
All of the Dockerfile for backend frontend and database was made by me with the help of Oguz Kagnici at the previous Milestone. This time again I was controlling the deploys and branch management and we faced issues while deploying our backend to GCP. To solve this problem I have changed our Dockerfile a little bit to make the build part of the deploy faster by prebuilding the Maven dependencies can be seen in this file at the line : "RUN mvn dependency:go-offline" . This change saved us since it was 3 am midnight on demo session day and we managed to deploy successfully.
Also with every new endpoint implemented I have provided corresponding updated Postman import file to the all of the group members.
For Unit Tests I used Junit and Mockito from my previous experiences. I also give a small tutorial Oguz how to write them in a Discord meeting. We divided the unit tests and wrote them in a very fast way. And at the end Oguz and I checked the other one's tests to be sure again in a Discord meeting. The Unit test structure and focuses were on this: The Service layer is the most important since all of the businness logic happens there so we needed to write Unit tests for services. I have wrote tests for User and Post Services. My main focus was to test all of the possible exceptions and all of the possible success scenarios. This way I was able to achieve a high percentage of coverage for the Unit Tests.
// Example Unit Test Code Snippet
@ExtendWith(MockitoExtension.class)
public class PostServiceTest {
@InjectMocks // To be tested service
private PostService postService;
@Mock // Mocking other dependencies to create a test environment
private PostRepository postRepository;
@Test // As understandable from its name it is a test case for the success scenario
public void searchPost_ReturnsResultsBasedOnLocation_WhenLocationIsPresent() {
// Arrange
User user = new User();
String param = "Soccer";
WikidataTeamDto teamDto = WikidataTeamDto.builder()
.teamName("Team1")
.location("Location1")
.build();
List<Post> posts = new ArrayList<>();
posts.add(new Post());
when(wikidataService.search(param)).thenReturn(teamDto);
when(postRepository.findByTextLikeIgnoreCaseParams(param, teamDto.getLocation())).thenReturn(posts);
// Act
SearchResponse result = postService.searchPost(user, param);
// Assert
assertEquals(1, result.getPosts().size()); // Assuming convertPostsToPostResponses returns the same number of posts
assertEquals(teamDto, result.getTeam());
}
@Test // And again this is an example for a fail scenario
public void create_ThrowsException_WhenUserNotAllowedToPost() {
// Arrange
Team userTeam = Team.GALATASARAY;
Team postTeam = Team.BESIKTAS;
Community community = Community.builder()
.team(userTeam)
.build();
User user = User.builder()
.community(community)
.build();
PostCreateRequest request = new PostCreateRequest();
request.setPostedAt(postTeam);
// Act & Assert
assertThatThrownBy(() -> postService.create(user, request))
.isInstanceOf(FanaticDatabaseException.class)
.hasMessageContaining("User can only post to their own community or global feed");
}
}
All of my other Unit tests followed this pattern.
🏠Home
- Third Customer Milestone Report
- RAM
- Requirements
- Mockups
- Sequence Diagrams
- Use Case Diagram
- Class Diagrams
- Scenarios
- User Scenario
- User Manual
- System Manual
- Third Customer Milestone Report
- Second Customer Milestone Report
- First Customer Milestone Report
- RAM
- Requirements
- Mockups
- Sequence Diagrams
- Scenarios
- Use Case Diagram
- Class Diagrams
- Software Quality Plan
- Milestone1 Presentation Scenarios
- Post Creation Page
- User Scenario
- Meeting Notes 10 - Dec 10
- Meeting Notes 9 - Dec 3
- Meeting Notes 8 - Nov 17
- Meeting Notes 7 - Nov 12
- Meeting Notes 6 - Nov 5
- Optional Meeting Notes 1 ‐ Oct 21
- Meeting Notes 5 - Oct 15
- Meeting Notes 4 - Oct 8
- Meeting Notes 3 - Oct 3
- Meeting Notes 2 - Oct 1
- Meeting Notes 1 - Sep 24
- Deniz Ulaş Poyraz
- Eren Donmez
- Ersel Çanakçılı
- Oğuz Kağnıcı
- Onur Çerli
- Yekta Ercul
- Ali Alperen Sönmez
- Huseyin Turker Erdem
- Mehmet Tuluyhan Sozen
352 Material
- Final Milestone Report
- Milestone 2 Report
- RAM
- Use Case Diagram
- Sequence Diagrams
- Class Diagrams
- Requirements
- Elicitation Questions
- Mockups
- Scenarios
- Milestone 1 Report
- Our Favourite Repositories
- Linked Data and SPARQL
- Web Application Development
- API Development and Utilization
- Wikidata and Wikidata API
- Mobile Application Development
- Android Studio
- Git
- Meeting Notes 10 ‐ May 10th
- Meeting Notes 9 ‐ Apr 25th
- Meeting Notes 8 ‐ Apr 21st
- Meeting Notes 7 ‐ Apr 12th
- Meeting Notes 6 ‐ Mar 14th
- Meeting Notes 5 ‐ Mar 11th
- Meeting Notes 4 - Mar 7th
- Meeting Notes 3 - Mar 3rd
- Meeting Notes 2 - Feb 22nd
- Meeting Notes 1 - Feb 18th