Skip to content

Commit

Permalink
Applied cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: pierantoniomerlino <[email protected]>
  • Loading branch information
pierantoniomerlino committed Nov 21, 2024
1 parent 3ee6c08 commit 8e4e179
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* Eurotech
*******************************************************************************/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2011, 2024 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* Eurotech
*******************************************************************************/
Expand Down Expand Up @@ -287,7 +287,7 @@ public static boolean toolExists(String tool) {
* Checks if the given Systemd system unit is installed.
* The result is based on the exit code of "systemctl status <unitName>"
* as presented in https://www.man7.org/linux/man-pages/man1/systemctl.1.html#EXIT_STATUS
*
*
* @param unitName
* the name of the Systemd system unit
* @return true if the unit is installed
Expand Down Expand Up @@ -1152,7 +1152,7 @@ public void createApNetworkInterface(String ifaceName, String dedicatedApInterfa
return;
}

CommandStatus status = this.executeCommand(formIwDevIfaceInterfaceAddAp(ifaceName, dedicatedApInterface));
CommandStatus status = executeCommand(formIwDevIfaceInterfaceAddAp(ifaceName, dedicatedApInterface));

if (!status.getExitStatus().isSuccessful()) {
throw new KuraException(KuraErrorCode.OS_COMMAND_ERROR,
Expand All @@ -1165,7 +1165,7 @@ public void setNetworkInterfaceMacAddress(String ifaceName) throws KuraException
return;
}

CommandStatus status = this.executeCommand(formIpLinkSetAddress(ifaceName, FAKE_MAC_ADDRESS));
CommandStatus status = executeCommand(formIpLinkSetAddress(ifaceName, FAKE_MAC_ADDRESS));

if (!status.getExitStatus().isSuccessful()) {
throw new KuraException(KuraErrorCode.OS_COMMAND_ERROR,
Expand All @@ -1178,7 +1178,7 @@ public void setNetworkInterfaceLinkUp(String ifaceName) throws KuraException {
return;
}

CommandStatus status = this.executeCommand(formIpLinkSetStatus(ifaceName, "up"));
CommandStatus status = executeCommand(formIpLinkSetStatus(ifaceName, "up"));

if (!status.getExitStatus().isSuccessful()) {
throw new KuraException(KuraErrorCode.OS_COMMAND_ERROR, "Failed to set link up for interface " + ifaceName);
Expand All @@ -1190,7 +1190,7 @@ public void setNetworkInterfaceLinkDown(String ifaceName) throws KuraException {
return;
}

CommandStatus status = this.executeCommand(formIpLinkSetStatus(ifaceName, "down"));
CommandStatus status = executeCommand(formIpLinkSetStatus(ifaceName, "down"));

if (!status.getExitStatus().isSuccessful()) {
throw new KuraException(KuraErrorCode.OS_COMMAND_ERROR, "Failed to set link up for interface " + ifaceName);
Expand All @@ -1208,8 +1208,8 @@ private CommandStatus executeCommand(String[] commandString) {

private static class StreamGobbler implements Runnable {

private InputStream inputStream;
private Consumer<String> consumer;
private final InputStream inputStream;
private final Consumer<String> consumer;

public StreamGobbler(InputStream inputStream, Consumer<String> consumer) {
this.inputStream = inputStream;
Expand All @@ -1218,7 +1218,7 @@ public StreamGobbler(InputStream inputStream, Consumer<String> consumer) {

@Override
public void run() {
new BufferedReader(new InputStreamReader(inputStream)).lines().forEach(consumer);
new BufferedReader(new InputStreamReader(this.inputStream)).lines().forEach(this.consumer);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2017, 2024 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* Eurotech
******************************************************************************/
Expand Down Expand Up @@ -326,7 +326,7 @@ public void shouldNotGetAnyTool() throws NoSuchFieldException {
@After
public void deregisterStaticMocks() {
if (this.mockedLinuxNetworkUtil != null) {
mockedLinuxNetworkUtil.close();
this.mockedLinuxNetworkUtil.close();
}
}

Expand All @@ -343,14 +343,14 @@ private void givenDhcpServerManager(DhcpServerTool dhcpServerTool) throws NoSuch

TestUtil.setFieldValue(new DhcpServerManager(null), "dhcpServerTool", dhcpServerTool);

this.dhcpServerManager = new DhcpServerManager(executorMock);
this.dhcpServerManager = new DhcpServerManager(this.executorMock);
}

private void givenLinuxNetworkUtil(String toolName, Optional<String> unitName) {
this.mockedLinuxNetworkUtil = Mockito.mockStatic(LinuxNetworkUtil.class);
mockedLinuxNetworkUtil.when(() -> LinuxNetworkUtil.toolExists(toolName)).thenReturn(true);
this.mockedLinuxNetworkUtil.when(() -> LinuxNetworkUtil.toolExists(toolName)).thenReturn(true);
if (unitName.isPresent()) {
mockedLinuxNetworkUtil.when(() -> LinuxNetworkUtil.systemdSystemUnitExists(unitName.get()))
this.mockedLinuxNetworkUtil.when(() -> LinuxNetworkUtil.systemdSystemUnitExists(unitName.get()))
.thenReturn(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright (c) 2022, 2024 Eurotech and/or its affiliates and others
*
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
*
* SPDX-License-Identifier: EPL-2.0
*
*
* Contributors:
* Eurotech
*******************************************************************************/
Expand Down

0 comments on commit 8e4e179

Please sign in to comment.