测试修改

main
liushujing 5 months ago
parent 2a14b3ea7b
commit 10d9c2daaa

@ -1,6 +1,7 @@
package com.pjilisense.flxai.controller; package com.pjilisense.flxai.controller;
import com.pjilisense.flxai.base.constant.Constant; import com.pjilisense.flxai.base.constant.Constant;
import com.pjilisense.flxai.dto.AppAiPluginDTO;
import com.pjilisense.flxai.page.PageData; import com.pjilisense.flxai.page.PageData;
import com.pjilisense.flxai.utils.Result; import com.pjilisense.flxai.utils.Result;
import com.pjilisense.flxai.dto.AppAiModelDTO; import com.pjilisense.flxai.dto.AppAiModelDTO;
@ -70,7 +71,7 @@ public class AppAiModelController {
appAiModelService.save(dto); appAiModelService.save(dto);
return new Result(); return new Result<AppAiModelDTO>().ok(dto);
} }
@PutMapping @PutMapping

@ -70,7 +70,7 @@ public class AppAiPluginController {
appAiPluginService.save(dto); appAiPluginService.save(dto);
return new Result(); return new Result<AppAiPluginDTO>().ok(dto);
} }
@PutMapping @PutMapping

@ -62,20 +62,14 @@ public class AppAiModelServiceImpl extends CrudServiceImpl<AppAiModelDao, AppAiM
retList.add(mapx); retList.add(mapx);
HashMap<String, Object> meta = new HashMap<>(); HashMap<String, Object> meta = new HashMap<>();
mapx.put("meta", meta); mapx.put("meta", meta);
meta.put("displayName", mapx.get("displayName")); meta.put("displayname", mapx.get("displayname"));
meta.put("description", mapx.get("description")); meta.put("description", mapx.get("description"));
meta.put("title", mapx.get("title")); meta.put("title", mapx.get("title"));
meta.put("enabled", mapx.get("enabled")); meta.put("enabled", mapx.get("enabled"));
meta.put("category", mapx.get("category")); meta.put("category", mapx.get("category"));
meta.put("metaId", mapx.get("metaId")); meta.put("id", mapx.get("metaId"));
meta.put("metaTokens", mapx.get("metaTokens")); meta.put("tokens", mapx.get("metaTokens"));
String tags = (String) mapx.get("tags"); mapx.remove("displayname");
if (tags!=null && tags.length() > 0) {
meta.put("tags", Arrays.asList(tags.split("\\,")));
} else {
meta.put("tags", new ArrayList<>());
}
mapx.remove("displayName");
mapx.remove("description"); mapx.remove("description");
mapx.remove("title"); mapx.remove("title");
mapx.remove("enabled"); mapx.remove("enabled");
@ -84,23 +78,23 @@ public class AppAiModelServiceImpl extends CrudServiceImpl<AppAiModelDao, AppAiM
mapx.remove("metaTokens"); mapx.remove("metaTokens");
String providers = (String) mapx.get("providers"); String providers = (String) mapx.get("providers");
if (providers!=null && providers.length() > 0) { if (providers!=null && providers.length() > 0) {
meta.put("providers", Arrays.asList(providers.split("\\,"))); mapx.put("providers", Arrays.asList(providers.split("\\,")));
} else { } else {
meta.put("providers", new ArrayList<>()); mapx.put("providers", new ArrayList<>());
} }
HashMap<String, Object> socialData = new HashMap<>(); HashMap<String, Object> socialData = new HashMap<>();
mapx.put("socialData", socialData); mapx.put("socialData", socialData);
meta.put("conversations", mapx.get("conversations")); socialData.put("conversations", mapx.get("conversations"));
meta.put("likes", mapx.get("likes")); socialData.put("likes", mapx.get("likes"));
meta.put("tokens", mapx.get("tokens")); socialData.put("tokens", mapx.get("tokens"));
mapx.remove("conversations"); mapx.remove("conversations");
mapx.remove("likes"); mapx.remove("likes");
mapx.remove("tokens"); mapx.remove("tokens");
String suggestions = (String) mapx.get("suggestions"); String suggestions = (String) mapx.get("suggestions");
if (suggestions!=null && suggestions.length() > 0) { if (suggestions!=null && suggestions.length() > 0) {
meta.put("suggestions", Arrays.asList(suggestions.split("\\,"))); mapx.put("suggestions", Arrays.asList(suggestions.split("\\,")));
} else { } else {
meta.put("suggestions", new ArrayList<>()); mapx.put("suggestions", new ArrayList<>());
} }
} }
} }

@ -0,0 +1,68 @@
/**
* Copyright (c) 2018 All rights reserved.
* <p>
* https://www.renren.io
* <p>
*
*/
package test.com.pjilisense.flxai.controller;
import com.alibaba.fastjson.JSON;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import test.com.pjilisense.flxai.TestUtils;
import java.util.HashMap;
import java.util.Map;
public class AppAiModelControllerTest {
@BeforeEach
public void setUpTestDataWithinTransaction() {
// set up test data within the transaction
}
@AfterEach
public void tearDownWithinTransaction() {
// execute "tear down" logic within the transaction
}
@Test
public void testAppAiAssistantSave() {
String url = TestUtils.WebconnectURL+"/api/robot/appaimodel";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("identifier","alps-tongyi-image2");
params.put("providers","ollama,YoungTx2");
params.put("conversations","0");
params.put("likes","0");
params.put("tokens","0");
params.put("description","此插件使用阿里巴巴的通义万象模型根据文本提示生成图像。");
params.put("displayname","Llama 3.1 8B");
params.put("enabled","true");
params.put("category","ollama");
params.put("title","Llama 3.1 8B");
params.put("metaId","llama3.1");
params.put("metaTokens","avatar2");
params.put("suggestions","a,b,c");
params.put("createdAt","2024-08-09");
params.put("userid","flx");
String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
System.out.println(body);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testGetAllAiAssistant() {
String url = TestUtils.WebconnectURL+"/api/robot/appaimodel/getAllAiModel?userid=flx";
String charset = TestUtils.UTF8;
try {
String body = TestUtils.doGet(url, charset);
System.out.println(body);
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,66 @@
/**
* Copyright (c) 2018 All rights reserved.
* <p>
* https://www.renren.io
* <p>
*
*/
package test.com.pjilisense.flxai.controller;
import com.alibaba.fastjson.JSON;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import test.com.pjilisense.flxai.TestUtils;
import java.util.HashMap;
import java.util.Map;
public class AppAiPluginControllerTest {
@BeforeEach
public void setUpTestDataWithinTransaction() {
// set up test data within the transaction
}
@AfterEach
public void tearDownWithinTransaction() {
// execute "tear down" logic within the transaction
}
@Test
public void testAppAiAssistantSave() {
String url = TestUtils.WebconnectURL+"/api/robot/appaiplugin";
String charset = TestUtils.UTF8;
try {
Map<String, Object> params = new HashMap<String, Object>();
params.put("author","YoungTx2");
params.put("homepage","https://github.com/YoungTx/alps-tongyi-image2");
params.put("identifier","alps-tongyi-image2");
params.put("locale","en-US");
params.put("manifest","https://alps-tongyi-image.vercel.app/manifest.json");
params.put("avatar","avatar2");
params.put("tags","图像,通义,万象");
params.put("title","通义万象图像生成器");
params.put("description","此插件使用阿里巴巴的通义万象模型根据文本提示生成图像。");
params.put("category","media-generate");
params.put("schemaVersion","1");
params.put("createdAt","2024-08-09");
params.put("userid","flx");
String body = TestUtils.doPost(url, JSON.toJSONString(params), charset);
System.out.println(body);
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testGetAllAiAssistant() {
String url = TestUtils.WebconnectURL+"/api/robot/appaiplugin/getAllAiPlugin?userid=flx";
String charset = TestUtils.UTF8;
try {
String body = TestUtils.doGet(url, charset);
System.out.println(body);
} catch (Exception e) {
e.printStackTrace();
}
}
}
Loading…
Cancel
Save