@@ -63,7 +63,8 @@ void createCitizenConsent_Ko_EmdEncryptError(){
63
63
mockedStatic .when (() -> Utils .createSHA256 (any ()))
64
64
.thenThrow (EmdEncryptionException .class );
65
65
66
- EmdEncryptionException exception = assertThrows (EmdEncryptionException .class , () -> citizenService .createCitizenConsent (citizenConsentDTO ));
66
+ assertThrows (EmdEncryptionException .class , () -> citizenService .createCitizenConsent (citizenConsentDTO ));
67
+
67
68
}
68
69
}
69
70
@@ -83,26 +84,14 @@ void deleteCitizenConsent_Ok(){
83
84
@ Test
84
85
void deleteCitizenConsent_Ko_UserNotOnboarded (){
85
86
CitizenConsentDTO citizenConsentDTO = CitizenConsentDTOFaker .mockInstance (false );
86
-
87
+ String hashedFiscalCode = citizenConsentDTO .getHashedFiscalCode ();
88
+ String channelId = citizenConsentDTO .getChannelId ();
87
89
Mockito .when (citizenRepository
88
90
.findByHashedFiscalCodeAndChannelId (Utils .createSHA256 (citizenConsentDTO .getHashedFiscalCode ()),citizenConsentDTO .getChannelId ()))
89
91
.thenReturn (null );
90
92
91
93
assertThrows (UserNotOnboardedException .class , () ->
92
- citizenService .deleteCitizenConsent (citizenConsentDTO .getHashedFiscalCode (),citizenConsentDTO .getChannelId ()));
93
- }
94
-
95
- @ Test
96
- void deleteCitizenConsent_Ko_EmdEncryptError (){
97
- CitizenConsentDTO citizenConsentDTO = CitizenConsentDTOFaker .mockInstance (true );
98
-
99
- try (MockedStatic <Utils > mockedStatic = Mockito .mockStatic (Utils .class )) {
100
- mockedStatic .when (() -> Utils .createSHA256 (any ()))
101
- .thenThrow (EmdEncryptionException .class );
102
-
103
- assertThrows (EmdEncryptionException .class , () ->
104
- citizenService .deleteCitizenConsent (citizenConsentDTO .getHashedFiscalCode (),citizenConsentDTO .getChannelId ()));
105
- }
94
+ citizenService .deleteCitizenConsent (hashedFiscalCode ,channelId ));
106
95
}
107
96
108
97
@ Test
@@ -118,27 +107,33 @@ void updateCitizenConsent_Ok(){
118
107
}
119
108
120
109
@ Test
121
- void updateCitizenConsent_Ko_UserNotOnboarded (){
110
+ void updateCitizenConsent_Ko_UserNotOnboarded () {
111
+
122
112
CitizenConsentDTO citizenConsentDTO = CitizenConsentDTOFaker .mockInstance (true );
123
113
124
- Mockito .when (citizenRepository
125
- .findByHashedFiscalCodeAndChannelId (Utils .createSHA256 (citizenConsentDTO .getHashedFiscalCode ()),citizenConsentDTO .getChannelId ()))
126
- .thenReturn (null );
114
+ String hashedFiscalCode = citizenConsentDTO .getHashedFiscalCode ();
115
+ String channelId = citizenConsentDTO .getChannelId ();
127
116
128
- assertThrows (UserNotOnboardedException .class , () ->
129
- citizenService .updateCitizenConsent (citizenConsentDTO .getHashedFiscalCode (),citizenConsentDTO .getChannelId ()));
117
+ Mockito .when (citizenRepository .findByHashedFiscalCodeAndChannelId (hashedFiscalCode , channelId ))
118
+ .thenReturn (null );
119
+
120
+ assertThrows (UserNotOnboardedException .class , () -> {
121
+ citizenService .updateCitizenConsent (hashedFiscalCode , channelId );
122
+ });
130
123
}
131
124
132
125
@ Test
133
- void updateCitizenConsent_Ko_EmdEncryptError (){
126
+ void citizenConsent_Ko_EmdEncryptError (){
134
127
CitizenConsentDTO citizenConsentDTO = CitizenConsentDTOFaker .mockInstance (true );
128
+ String hashedFiscalCode = citizenConsentDTO .getHashedFiscalCode ();
129
+ String channelId = citizenConsentDTO .getChannelId ();
135
130
136
131
try (MockedStatic <Utils > mockedStatic = Mockito .mockStatic (Utils .class )) {
137
132
mockedStatic .when (() -> Utils .createSHA256 (any ()))
138
133
.thenThrow (EmdEncryptionException .class );
139
134
140
135
assertThrows (EmdEncryptionException .class , () ->
141
- citizenService .deleteCitizenConsent (citizenConsentDTO . getHashedFiscalCode (), citizenConsentDTO . getChannelId () ));
136
+ citizenService .deleteCitizenConsent (hashedFiscalCode , channelId ));
142
137
}
143
138
}
144
139
}
0 commit comments