Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -136,6 +136,12 @@ public File generateAgentConfigFile(String agentId) {
AgentUser agentUser = getAgent(agentId);
if (agentUser != null) {
try {
File tempFolder = new File(CenterConstant.CENTER_TEMP_FILE_DIR);
if (!tempFolder.exists()){
if (!tempFolder.mkdirs()) {
throw new RuntimeException("mkdirs fail for: " + tempFolder);
}
}
File agentConfigFile = File.createTempFile(
"application",
".yml",
Expand Down
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");
}
}