Skip to content

Commit

Permalink
Fixing SonarLint recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
RobFaustLZ committed Jun 4, 2024
1 parent 1df6a71 commit 9f3bbab
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/labelzoom/moca/LegacyMocaConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected MocaResponse send(String command) throws MocaException

final byte[] data = new byte[socket.getInputStream().available()];
final int bytes = socket.getInputStream().read(data, 0, data.length);
final String responseData = new String(data, 0 , bytes, "ASCII");
final String responseData = new String(data, 0 , bytes, StandardCharsets.US_ASCII);
return MocaResponse.fromLegacy(responseData);
}
catch (final IOException | InterruptedException ex)
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/labelzoom/moca/MocaConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.labelzoom.moca.exceptions.MocaException;

import java.io.Closeable;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/labelzoom/moca/MocaResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class MocaResultSet extends AbstractResultSet

private int rowNum = -1;

public MocaResultSet(final Node mocaResults) throws SQLException
public MocaResultSet(final Node mocaResults)
{
final Node metadata = ((Element)mocaResults).getElementsByTagName("metadata").item(0);
this.metadata = new MocaResultSetMetaData(metadata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

public class MocaExceptionFactory
{
private MocaExceptionFactory() {}

public static MocaException produce(final String message, final int code) { return produce(message, code, null); }
public static MocaException produce(final String message, final int code, final ResultSet results)
{
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/labelzoom/moca/HttpMocaConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import static org.junit.jupiter.api.Assertions.*;

public class HttpMocaConnectionTest
class HttpMocaConnectionTest
{
private final String url = System.getenv("MOCA_URL");
private final String userId = System.getenv("MOCA_USER");
Expand All @@ -32,7 +32,7 @@ public void testEnvironmentSetup()
}

@Test
public void testHttpMocaConnection() throws MocaException, IOException, SQLException
void testHttpMocaConnection() throws MocaException, SQLException
{
try (final MocaConnection conn = new HttpMocaConnection(url, userId, password);
final ResultSet res = conn.execute("publish data where message = 'My name is Rob'"))
Expand All @@ -43,7 +43,7 @@ public void testHttpMocaConnection() throws MocaException, IOException, SQLExcep
}

@Test
public void testMultipleRows() throws MocaException, IOException, SQLException
void testMultipleRows() throws MocaException, SQLException
{
try (final MocaConnection conn = new HttpMocaConnection(url, userId, password);
final ResultSet res = conn.execute("publish data where a = 1 and b = 2 & publish data where a = 3 and b = 4"))
Expand All @@ -56,7 +56,7 @@ public void testMultipleRows() throws MocaException, IOException, SQLException
}

@Test
public void testRawHttp() throws IOException
void testRawHttp() throws IOException
{
final int TIMEOUT = 5000;
final String command = "<moca-request><query>get encryption information</query></moca-request>";
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/com/labelzoom/moca/LegacyMocaConnectionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* TODO: LegacyMocaConnection needs some work
*/
@Disabled
public class LegacyMocaConnectionTest
class LegacyMocaConnectionTest
{
private final String host = System.getenv("MOCA_HOST");
private final int port = Integer.parseInt(System.getenv("MOCA_PORT"));
Expand All @@ -42,7 +42,7 @@ public void testEnvironmentSetup()
}

@Test
public void testReadersAndWriters() throws IOException, InterruptedException
void testReadersAndWriters() throws IOException
{
try (final Socket socket = new Socket(host, port))
{
Expand All @@ -68,7 +68,7 @@ public void testReadersAndWriters() throws IOException, InterruptedException
}

@Test
public void testRawV103() throws IOException, InterruptedException
void testRawV103() throws IOException, InterruptedException
{
try (final Socket socket = new Socket(host, port))
{
Expand All @@ -88,7 +88,7 @@ public void testRawV103() throws IOException, InterruptedException
}

@Test
public void testRawV104() throws IOException, InterruptedException
void testRawV104() throws IOException, InterruptedException
{
try (final Socket socket = new Socket(host, port))
{
Expand All @@ -108,7 +108,7 @@ public void testRawV104() throws IOException, InterruptedException
}

@Test
public void testLegacyMocaConnection() throws MocaException
void testLegacyMocaConnection() throws MocaException
{
try (final MocaConnection conn = new LegacyMocaConnection(host, port, userId, password);
final ResultSet res = conn.execute("create policy where polcod = 'LEGACY-MOCA-CLIENT' and polvar = 'LEGACY-MOCA-CLIENT' and polval = 'LEGACY-MOCA-CLIENT' and rtstr1 = 'success'"))
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/labelzoom/moca/MocaRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import org.junit.jupiter.api.Test;

public class MocaRequestTest
class MocaRequestTest
{
@Test
public void testMocaResultXml()
void testMocaResultXml()
{
final MocaRequest request = MocaRequestBuilder.http().command("login user where usr_id = 'RFAUST' and usr_paswd = 'RFaust123'");
System.out.println(request.toString());
}
@Test
public void testMocaResultLegacy()
void testMocaResultLegacy()
{
final MocaRequest request = MocaRequestBuilder.legacy().command("login user where usr_id = 'RFAUST' and usr_paswd = 'RFaust123'");
System.out.println(request.toString());
Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/labelzoom/moca/MocaResultSetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import static org.junit.jupiter.api.Assertions.*;

public class MocaResultSetTest extends MocaTester
class MocaResultSetTest extends MocaTester
{
@Test
public void testIteration() throws MocaException, SQLException
void testIteration() throws MocaException, SQLException
{
try (final ResultSet res = conn.execute("publish data where a = 1 and b = 2 & publish data where a = 3 and b = 4"))
{
Expand Down Expand Up @@ -55,7 +55,7 @@ public void testIteration() throws MocaException, SQLException
}

@Test
public void testDataTypes() throws MocaException, SQLException
void testDataTypes() throws MocaException, SQLException
{
try (final ResultSet res = conn.execute("publish data" +
" where intcol = 82332" +
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/labelzoom/moca/MocaTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected void setUp() throws Exception
}

@AfterEach
protected void tearDown() throws Exception
protected void tearDown()
{
conn.close();
}
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/com/labelzoom/moca/MocaTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@

import static org.junit.jupiter.api.Assertions.*;

public class MocaTests extends MocaTester
class MocaTests extends MocaTester
{
@Test
public void testSyntaxError()
void testSyntaxError()
{
final MocaException ex = assertThrows(MocaException.class, () -> conn.execute("publish data a = 1"));
System.err.println(ex.getMessage());
assertEquals(505, ex.getErrorCode());
}

@Test
public void testCommandNotFound()
void testCommandNotFound()
{
final MocaException ex = assertThrows(MocaException.class, () -> conn.execute("this command doesnt exist"));
System.err.println(ex.getMessage());
assertEquals(501, ex.getErrorCode());
}

@Test
public void testNoRowsAffected() throws SQLException
void testNoRowsAffected() throws SQLException
{
final MocaException ex = assertThrows(MocaException.class, () -> conn.execute("[select polcod, polvar, polval from poldat where 1 = 2]"));
System.err.println(ex.getMessage());
Expand All @@ -40,7 +40,7 @@ public void testNoRowsAffected() throws SQLException
}

@Test
public void testInvalidColumn() throws SQLException
void testInvalidColumn()
{
final MocaException ex = assertThrows(MocaException.class, () -> conn.execute("[select qw9io0ejoower from poldat where 1 = 2]"));
System.err.println(ex.getMessage());
Expand Down

0 comments on commit 9f3bbab

Please sign in to comment.