Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean code and fix sonar issues #174

Merged
merged 50 commits into from
Mar 5, 2025
Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3d47d3e
JwtTokenNeededFilter : skipTokenValidityCheck becomes final
rolnico Feb 14, 2025
c5646a2
Clean Utils
rolnico Feb 14, 2025
3aff3ea
Create SafeLogger class and use it
rolnico Feb 14, 2025
60ae956
add comment
rolnico Feb 14, 2025
1e520f0
clean EventsTest
rolnico Feb 14, 2025
3ac12fc
use regex: !([\w().]+)\.isPresent\(\)
rolnico Feb 14, 2025
405bf9f
clean NodeInfoTest
rolnico Feb 14, 2025
c0e845a
remove method same as parent
rolnico Feb 14, 2025
c38bef2
clean ActionScriptTest
rolnico Feb 14, 2025
c2075cf
replace ImmutableList.of with List.of
rolnico Feb 14, 2025
01a2249
clean import and some checkstyle
rolnico Feb 14, 2025
a7a0dda
clean part of AppData
rolnico Feb 14, 2025
c93e1ab
clean part of AppFileSystem
rolnico Feb 14, 2025
076cb46
clean part of AppFileSystemTool
rolnico Feb 14, 2025
2a79c7f
clean LocalTaskMonitor
rolnico Feb 14, 2025
39fd6aa
clean AbstractProjectFileTest
rolnico Feb 14, 2025
adc251b
start to clean AfsBaseTest
rolnico Feb 14, 2025
8f3d077
clean AfsBaseTest
rolnico Feb 17, 2025
324054a
clean LocalTaskMonitorTest
rolnico Feb 17, 2025
d6a4528
add deprecation date on AbstractModificationScript
rolnico Feb 17, 2025
83a575c
clean AbstractScript
rolnico Feb 17, 2025
0c8440a
clean ImportedCaseTest
rolnico Feb 17, 2025
ddc7f6c
clean ModificationScriptTest + create GenericScriptTest
rolnico Feb 17, 2025
5dce23d
clean GenericScriptTest
rolnico Feb 17, 2025
833357a
clean TestImporter
rolnico Feb 17, 2025
f32459f
clean VirtualCaseTest
rolnico Feb 18, 2025
aa1b57d
clean LocalAppFileSystemConfigTest
rolnico Feb 18, 2025
61bd6dd
clean LocalAppFileSystemProviderTest
rolnico Feb 18, 2025
ea9ffd8
clean LocalAppStorageTest
rolnico Feb 18, 2025
4a1398b
clean some classes
rolnico Feb 20, 2025
a3f072a
clean NodeGenericMetadataTest
rolnico Feb 21, 2025
c7552b7
clean NodeInfoTest
rolnico Feb 21, 2025
47bb97e
clean UtilsTest
rolnico Feb 21, 2025
42cd73e
clean StorageChangeTest
rolnico Feb 21, 2025
d09994b
clean NodeEventTest
rolnico Feb 21, 2025
ed8ce3d
add RemoteAppFileSystemProviderTest
rolnico Feb 21, 2025
f284fe9
make ExceptionDetail a record and add ExceptionDetailTest
rolnico Feb 24, 2025
29fddac
remove CodeCoverageTest fake classes
rolnico Feb 24, 2025
35396ae
Merge branch 'main' into nro/fix_sonar_issues
rolnico Feb 24, 2025
8afa671
remove public modifier
rolnico Feb 24, 2025
17212a0
test on MapDbAppStorageTest
rolnico Feb 24, 2025
59ce99f
add tests
rolnico Feb 24, 2025
c0a2b88
fix import
rolnico Feb 24, 2025
6de16e1
fix imports
rolnico Feb 24, 2025
8094c28
disable test
rolnico Feb 24, 2025
4f77233
remove modifier
rolnico Feb 24, 2025
99c739c
Merge branch 'main' into nro/fix_sonar_issues
rolnico Mar 4, 2025
d685d8a
revert modifications on Utils.unzip as they will be done in another PR
rolnico Mar 5, 2025
8e4c15a
changed comment on AbstractModificationScript deprecation
rolnico Mar 5, 2025
8bc7f5b
remove test until it works
rolnico Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
package com.powsybl.afs.ws.client.utils;

import com.powsybl.commons.net.UserProfile;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.Invocation;
import jakarta.ws.rs.client.WebTarget;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.core.Response;
import org.mockito.MockedStatic;
import org.mockito.Mockito;

import java.net.URI;
Expand All @@ -23,6 +28,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;

/**
Expand Down Expand Up @@ -77,17 +83,29 @@ void testReadOptionalEntityIfOkWithNotFound() {
}

@Test
@Disabled("Fix me")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me why the test fails at the moment...

void testAuthenticate() {
URI baseUri = URI.create("http://localhost");
String login = "user";
String password = "password";

try (Client client = mock(Client.class);
Response response = mock(Response.class)) {
try (MockedStatic<ClientUtils> mockedClientUtils = mockStatic(ClientUtils.class)) {
Client client = mock(Client.class);
WebTarget webTarget = mock(WebTarget.class);
Invocation.Builder builder = mock(Invocation.Builder.class);
Response response = mock(Response.class);

mockedClientUtils.when(ClientUtils::createClient).thenReturn(client);

when(client.target(baseUri)).thenReturn(webTarget);
when(webTarget.path("rest")).thenReturn(webTarget);
when(webTarget.path("users")).thenReturn(webTarget);
when(webTarget.path("login")).thenReturn(webTarget);
when(webTarget.request()).thenReturn(builder);
when(builder.post(any(Entity.class))).thenReturn(response);
when(response.getStatus()).thenReturn(Response.Status.OK.getStatusCode());
when(response.readEntity(UserProfile.class)).thenReturn(new UserProfile("firstName", "lastName"));
when(response.getHeaderString(Mockito.anyString())).thenReturn("auth-token");
when(client.target(any(URI.class))).thenReturn(mock(jakarta.ws.rs.client.WebTarget.class));

UserSession session = ClientUtils.authenticate(baseUri, login, password);
assertNotNull(session);
Expand Down