Skip to content

Commit ef4f74d

Browse files
committed
Refactoring: Remove 'getCommand' method in 'AlertLogCommand' Model
1 parent add3555 commit ef4f74d

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/main/java/root/core/domain/AlertLogCommand.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ public AlertLogCommand(String readLine, String readFilePath, String... catchErro
2929
this.readFilePath = readFilePath;
3030
this.catchErrorMsg = catchErrorMsg;
3131
}
32-
33-
// TODO OSº° command ÀÛ¼º
34-
public String getCommand() {
35-
return "tail -" + this.getReadLine() + " " + this.getReadFilePath();
36-
}
3732
}

src/main/java/root/core/repository/implement/LinuxServerMonitoringRepository.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public String checkAlertLog(AlertLogCommand alc) {
8383
try {
8484
Session session = this.getSession();
8585
session = this.connectSession(session);
86-
Channel channel = jsch.openExecChannel(session, alc.getCommand());
86+
String command = "tail -" + alc.getReadLine() + " " + alc.getReadFilePath();
87+
Channel channel = jsch.openExecChannel(session, command);
8788
InputStream in = jsch.connectChannel(channel);
8889
result = IOUtils.toString(in, "UTF-8");
8990
jsch.disConnectChannel(channel);

src/test/java/root/core/repository/implement/LinuxServerMonitoringRepositoryTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public void checkAlertLogTest() {
7272
InputStream in = new ByteArrayInputStream(alertLogString.getBytes());
7373

7474
when(repo.getSession()).thenReturn(session);
75-
when(jsch.openExecChannel(session, alc.getCommand())).thenReturn(channel);
75+
String command = "tail -" + alc.getReadLine() + " " + alc.getReadFilePath();
76+
when(jsch.openExecChannel(session, command)).thenReturn(channel);
7677
when(jsch.connectChannel(channel)).thenReturn(in);
7778
doNothing().when(jsch).disConnectChannel(channel);
7879
doNothing().when(channel).disconnect();
@@ -118,7 +119,8 @@ public void checkAlertLogDuringPeriod() {
118119
doNothing().when(jsch).disConnectChannel(channel2);
119120
doNothing().when(channel2).disconnect();
120121

121-
when(jsch.openExecChannel(session, alc.getCommand())).thenReturn(channel);
122+
String command = "tail -" + alc.getReadLine() + " " + alc.getReadFilePath();
123+
when(jsch.openExecChannel(session, command)).thenReturn(channel);
122124
when(jsch.connectChannel(channel)).thenReturn(in);
123125
doNothing().when(jsch).disConnectChannel(channel);
124126
doNothing().when(channel).disconnect();

0 commit comments

Comments
 (0)