-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TRIB-236: adds ConnectAPI endpoints to get all cosigners for user and…
… all cosigners for a given attribute (#162) * TRIB-236: adds UserNameDTO * TRIB-236: removes unused imports from UserNameDTO * TRIB-236: adds cosign repo query for cosigners - adds findCosignersByUserIdReceivingAndPhraseId * TRIB-236: adds cosign svc get cosigners() - adds List<UserNameDTO> getCosignersForUserAttribute(Long userReceivingId, Long phraseId) * TRIB-236: adds connectAPI endpoint to get cosignrs - adds getCosignersForUserAttribute * TRIB-236: updates cnnct endpoint get cosigners rtn - updates getCosignersForUserAttribute return type to ResponseEntity<List<UserNameDTO>> * TRIB-236: creates Cosigns for users dto * TRIB-236: adds Schema notations to CosignDTO - reasoning: Noticed error in cosign DTO. Added schema notations for fields. Possibly unrelated to this ticket, but may become relevant if cosignDTO ends up being incorporated. * TRIB-236: updates CosignsForUserDTO list property - updates list of cosigners to match ticket output requirement: listOfCosigners * TRIB-236:adds cosign repo findAllByUserIdReceiving * TRIB-236: adds connectapi & cosign svc getAllCosgn - adds cosign service getAllCosignsForUser - adds connectapi endpoing getAllCosignsForUser * TRIB-236: refactors cosign svc to use user svc - adds getUserNameDTO to user services - refactors cosign service getCosignersForUserAttribute and getAllCosignsForUser to call user service for getUserNameDTO - reasoning: relocating user-related methods to the user service instead of "hiding" them in the cosign service * TRIB-236: adds test for user svc getUserNameDTO * TRIB-236: adds test for cosign svc getCosigners * TRIB-236: adds connectSvc testGetAllCosignsForUser * TRIB-236: refactors cosign test for clarity * TRIB-236: adds CnctAPI test get cosigns user/attr * TRIB-236: adds CnctAPI testGetAllCosignsForUser * TRIB-236: adds CnctAPI swagger annotation * TRIB-236: adds ConnectAPI swagger annotation * TRIB-236: changes userName to username in multiple * TRIB-236: updates cosignforuserDTO schema * TRIB-236: adds connect svc test for Get Cosigners - adds test testGetCosignersForUserWithThreeCosigners * TRIB-236: cnc * TRIB-236: adds connect svc test get all cosigns - added a second test testGetAllCosignsForUserWithThreeCosignsForThreePhrases to test multiple list entries - added class helper method listBuilderCosignForUser to build cosigns for a user - reasoning for helper method: It was already a long test, and creating 9 cosigns required 54 lines of code. Using the helper method reduced the code to 15 lines. * TRIB-236: updates connectAPI get all cosigns test - updates testGetAllCosignsForUser() to test for three phrases, each with three cosigners - removed phraseId from parameter list (mistake) * TRIB-236: removes sout print lines used for dev
- Loading branch information
1 parent
f5d977a
commit 1288903
Showing
14 changed files
with
583 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ibeapp/controllers/annotations/controllers/ConnectAPIController/GetAllCosignsForUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.savvato.tribeapp.controllers.annotations.controllers.ConnectAPIController; | ||
|
||
import com.savvato.tribeapp.controllers.annotations.responses.BadRequest; | ||
import com.savvato.tribeapp.controllers.annotations.responses.Success; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
|
||
import java.lang.annotation.*; | ||
|
||
/** Documentation for getting all cosigns for a user */ | ||
@Target({ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Operation( | ||
summary = "Get all cosigners of attributes for a given attribute for a user", | ||
description = "Provided a user ID, get cosigns and attribute ids for that user. ") | ||
@Success(description = "", example = "") | ||
@BadRequest(description = "", noContent = true) | ||
public @interface GetAllCosignsForUser {} |
17 changes: 17 additions & 0 deletions
17
...ontrollers/annotations/controllers/ConnectAPIController/GetCosignersForUserAttribute.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.savvato.tribeapp.controllers.annotations.controllers.ConnectAPIController; | ||
|
||
import com.savvato.tribeapp.controllers.annotations.responses.BadRequest; | ||
import com.savvato.tribeapp.controllers.annotations.responses.Success; | ||
import io.swagger.v3.oas.annotations.Operation; | ||
import java.lang.annotation.*; | ||
|
||
/** Documentation for getting cosigns for a user attribute */ | ||
@Target({ElementType.METHOD, ElementType.TYPE, ElementType.ANNOTATION_TYPE}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Documented | ||
@Operation( | ||
summary = "Get all cosigners for a given attribute for a user", | ||
description = "Provided a user ID and attribute ID, get cosigns for that user and attribute. ") | ||
@Success(description = "", example = "") | ||
@BadRequest(description = "", noContent = true) | ||
public @interface GetCosignersForUserAttribute {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/com/savvato/tribeapp/dto/CosignsForUserDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.savvato.tribeapp.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@Schema(description = "All Cosigns for user DTO") | ||
@Builder | ||
public class CosignsForUserDTO { | ||
|
||
@Schema(example = "1") | ||
public long phraseId; | ||
|
||
@Schema(example = "[{\"userId\": 1, \"username\": \"testuser\"}]") | ||
public List<UsernameDTO> listOfCosigners; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.savvato.tribeapp.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Builder; | ||
|
||
@Builder | ||
public class UsernameDTO { | ||
@Schema(example = "1") | ||
public Long userId; | ||
|
||
@Schema(example = "John Doe") | ||
public String username; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 7 additions & 1 deletion
8
src/main/java/com/savvato/tribeapp/services/CosignService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
package com.savvato.tribeapp.services; | ||
|
||
import com.savvato.tribeapp.dto.CosignDTO; | ||
import com.savvato.tribeapp.dto.CosignsForUserDTO; | ||
import com.savvato.tribeapp.dto.UsernameDTO; | ||
|
||
import java.util.Optional; | ||
import java.util.List; | ||
|
||
public interface CosignService { | ||
|
||
CosignDTO saveCosign(Long userIdIssuing, Long userIdReceiving, Long phraseId); | ||
boolean deleteCosign(Long userIdIssuing, Long userIdReceiving, Long phraseId); | ||
|
||
List<UsernameDTO> getCosignersForUserAttribute(Long userReceivingId, Long phraseId); | ||
|
||
List<CosignsForUserDTO> getAllCosignsForUser(Long userIdReceiving); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.