-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix directory not existing issue (#237)
* Fix directory not existing issue; Add UT for agent file downloading;
- Loading branch information
1 parent
35be2ad
commit 0e978a0
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
center/src/test/java/com/microsoft/hydralab/center/service/AgentManageServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.microsoft.hydralab.center.service; | ||
|
||
import com.microsoft.hydralab.common.entity.center.AgentUser; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
|
||
import java.io.File; | ||
|
||
import static org.mockito.Mockito.doReturn; | ||
|
||
public class AgentManageServiceTest { | ||
|
||
@Test | ||
void putData() { | ||
String agentId = "test_agent_id"; | ||
AgentManageService agentManageService = Mockito.spy(AgentManageService.class); | ||
AgentUser agent = new AgentUser(); | ||
agent.setName("Agent Name"); | ||
agent.setId(agentId); | ||
agent.setSecret("Agent Secret"); | ||
doReturn(agent).when(agentManageService).getAgent(agentId); | ||
|
||
File file = agentManageService.generateAgentConfigFile(agentId); | ||
Assertions.assertNotNull(file, "Get agent user error"); | ||
Assertions.assertTrue(file.length() > 0, "Write agent config file error"); | ||
} | ||
} |