[Delete] Core, Framework-API 移除 BotCode 的 'getPlatform' 方法;

[Delete] BotCode 移除目前尚未使用的 'getPlatform' 方法, 该方法在开发 BotCode 具体实现时带来了一些麻烦;
[Delete] BasicBotCode, BasicBotCodeTest, AbstractBotCode, AbstractBotCodeTest, MessageChainTest 适配修改;
This commit is contained in:
LamGC 2021-02-03 12:13:32 +08:00
parent 672be33866
commit 612956b594
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D
6 changed files with 2 additions and 41 deletions

View File

@ -47,11 +47,6 @@ public class BasicBotCode extends AbstractBotCode {
super(function, functionProperties); super(function, functionProperties);
} }
@Override
public Platform getPlatform() {
return PLATFORM;
}
@Override @Override
public String contentToString() { public String contentToString() {
StringBuilder builder = new StringBuilder('[' + getFunction().getFunctionName()); StringBuilder builder = new StringBuilder('[' + getFunction().getFunctionName());

View File

@ -17,7 +17,6 @@
package net.lamgc.cgj.bot.framework.base; package net.lamgc.cgj.bot.framework.base;
import net.lamgc.cgj.bot.framework.Platform;
import net.lamgc.cgj.bot.framework.message.AbstractBotCode; import net.lamgc.cgj.bot.framework.message.AbstractBotCode;
import net.lamgc.cgj.bot.framework.message.BotCode; import net.lamgc.cgj.bot.framework.message.BotCode;
import net.lamgc.cgj.bot.framework.message.BotCodeFunction; import net.lamgc.cgj.bot.framework.message.BotCodeFunction;
@ -33,14 +32,6 @@ import java.util.Map;
*/ */
public class BasicBotCodeTest { public class BasicBotCodeTest {
@Test
public void getPlatform() {
BotCode botCode = new BasicBotCode(StandardBotCodeFunction.AT);
Assert.assertEquals("ContentGrabbingJi", botCode.getPlatform().getPlatformName());
Assert.assertEquals("CGJ", botCode.getPlatform().getPlatformIdentify());
}
@Test @Test
public void contentToStringWithoutParameter() { public void contentToStringWithoutParameter() {
BotCode botCode = new BasicBotCode(StandardBotCodeFunction.FILE); BotCode botCode = new BasicBotCode(StandardBotCodeFunction.FILE);
@ -67,11 +58,6 @@ public class BasicBotCodeTest {
super(function, functionProperties); super(function, functionProperties);
} }
@Override
public Platform getPlatform() {
return null;
}
@Override @Override
public String contentToString() { public String contentToString() {
return null; return null;

View File

@ -72,7 +72,6 @@ public abstract class AbstractBotCode implements BotCode {
mapString.delete(mapString.length() - 2, mapString.length()); mapString.delete(mapString.length() - 2, mapString.length());
} }
return this.getClass().getSimpleName() + '@' + Integer.toHexString(this.hashCode()) + '{' + return this.getClass().getSimpleName() + '@' + Integer.toHexString(this.hashCode()) + '{' +
"Platform=" + getPlatform() + ", " +
"functionName='" + function.getFunctionName() + '\'' + "functionName='" + function.getFunctionName() + '\'' +
", functionProperties={" + mapString.toString() + '}' + ", functionProperties={" + mapString.toString() + '}' +
'}'; '}';

View File

@ -17,8 +17,6 @@
package net.lamgc.cgj.bot.framework.message; package net.lamgc.cgj.bot.framework.message;
import net.lamgc.cgj.bot.framework.Platform;
import java.util.Set; import java.util.Set;
/** /**
@ -28,12 +26,6 @@ import java.util.Set;
@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc") @SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
public interface BotCode extends Message { public interface BotCode extends Message {
/**
* 获取 BotCode 实现所属平台.
* @return 返回所属平台.
*/
Platform getPlatform();
/** /**
* 取功能函数名. * 取功能函数名.
* @return 返回功能函数名. * @return 返回功能函数名.

View File

@ -17,7 +17,6 @@
package net.lamgc.cgj.bot.framework.message; package net.lamgc.cgj.bot.framework.message;
import net.lamgc.cgj.bot.framework.Platform;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@ -125,13 +124,13 @@ public class AbstractBotCodeTest {
public void toStringTest() { public void toStringTest() {
BotCode botCode = new TestBotCode("function"); BotCode botCode = new TestBotCode("function");
String objectStr = botCode.getClass().getSimpleName() + '@' + Integer.toHexString(botCode.hashCode()); String objectStr = botCode.getClass().getSimpleName() + '@' + Integer.toHexString(botCode.hashCode());
Assert.assertEquals(objectStr + "{Platform=null, functionName='function', " + Assert.assertEquals(objectStr + "{functionName='function', " +
"functionProperties={Hashtable}}", botCode.toString()); "functionProperties={Hashtable}}", botCode.toString());
botCode.setProperty("arg1", "value1"); botCode.setProperty("arg1", "value1");
botCode.setProperty("arg2", "测试"); botCode.setProperty("arg2", "测试");
botCode.setProperty("arg3", "Hello World."); botCode.setProperty("arg3", "Hello World.");
Assert.assertEquals(objectStr + "{Platform=null, functionName='function', " + Assert.assertEquals(objectStr + "{functionName='function', " +
"functionProperties={Hashtable{\"arg1\"='value1', \"arg2\"='测试', \"arg3\"='Hello World.'}}", "functionProperties={Hashtable{\"arg1\"='value1', \"arg2\"='测试', \"arg3\"='Hello World.'}}",
botCode.toString()); botCode.toString());
} }
@ -154,11 +153,6 @@ public class AbstractBotCodeTest {
super(function, functionProperties); super(function, functionProperties);
} }
@Override
public Platform getPlatform() {
return null;
}
@Override @Override
public String contentToString() { public String contentToString() {
return null; return null;

View File

@ -76,11 +76,6 @@ public class MessageChainTest {
public void plusBotCodeTest() { public void plusBotCodeTest() {
MessageChain chain = new MessageChain("BotCode: "); MessageChain chain = new MessageChain("BotCode: ");
chain.plus(new AbstractBotCode(StandardBotCodeFunction.AT) { chain.plus(new AbstractBotCode(StandardBotCodeFunction.AT) {
@Override
public Platform getPlatform() {
return null;
}
@Override @Override
public String contentToString() { public String contentToString() {
return "[at:arg=value]"; return "[at:arg=value]";