Search in sources :

Example 1 with AnnotatedTemplatedBehaviourTest

use of co.aurasphere.botmill.fb.test.autoreply.template.AnnotatedTemplatedBehaviourTest in project fb-botmill by BotMill.

the class AnnotatedTemplateTest method setup.

@Before
public void setup() {
    Assume.assumeTrue(isConfigurationExist());
    FbBotMillContext.getInstance().setup(System.getenv("fb.page.token"), System.getenv("fb.validation.token"));
    //	Load the Bot manually.
    List<BotDefinition> botDefs = new ArrayList<BotDefinition>();
    botDefs.add(new AnnotatedTemplatedBehaviourTest());
    ConfigurationUtils.setBotDefinitionInstance(botDefs);
}
Also used : BotDefinition(co.aurasphere.botmill.core.BotDefinition) ArrayList(java.util.ArrayList) AnnotatedTemplatedBehaviourTest(co.aurasphere.botmill.fb.test.autoreply.template.AnnotatedTemplatedBehaviourTest) Before(org.junit.Before)

Example 2 with AnnotatedTemplatedBehaviourTest

use of co.aurasphere.botmill.fb.test.autoreply.template.AnnotatedTemplatedBehaviourTest in project fb-botmill by BotMill.

the class AnnotatedTemplateTest method main.

public static void main(String[] args) {
    StandardPBEStringEncryptor enc = new StandardPBEStringEncryptor();
    // can be sourced out
    enc.setPassword("password");
    ConfigurationUtils.loadEncryptedConfigurationFile(enc, "botmill.properties");
    List<BotDefinition> botDef = new ArrayList<BotDefinition>();
    botDef.add(new AnnotatedTemplatedBehaviourTest());
    ConfigurationUtils.loadBotConfig();
    ConfigurationUtils.setBotDefinitionInstance(botDef);
    for (int i = 0; i < 10; i++) {
        new Thread(new Runnable() {

            String json = "{\"sender\":{\"id\":\"1158621824216736\"},\"recipient\":{\"id\":\"1226565047419159\"},\"timestamp\":1490832021661,\"message\":{\"mid\":\"mid.$cAAUPCFn4ymdhTcignVbHH3rzpKd_\",\"seq\":844819,\"text\":\"Hi!\"}}";

            MessageEnvelope envelope = FbBotMillJsonUtils.fromJson(json, MessageEnvelope.class);

            @Override
            public void run() {
                try {
                    IncomingToOutgoingMessageHandler.getInstance().process(envelope);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}
Also used : BotDefinition(co.aurasphere.botmill.core.BotDefinition) StandardPBEStringEncryptor(org.jasypt.encryption.pbe.StandardPBEStringEncryptor) ArrayList(java.util.ArrayList) MessageEnvelope(co.aurasphere.botmill.fb.model.incoming.MessageEnvelope) AnnotatedTemplatedBehaviourTest(co.aurasphere.botmill.fb.test.autoreply.template.AnnotatedTemplatedBehaviourTest)

Aggregations

BotDefinition (co.aurasphere.botmill.core.BotDefinition)2 AnnotatedTemplatedBehaviourTest (co.aurasphere.botmill.fb.test.autoreply.template.AnnotatedTemplatedBehaviourTest)2 ArrayList (java.util.ArrayList)2 MessageEnvelope (co.aurasphere.botmill.fb.model.incoming.MessageEnvelope)1 StandardPBEStringEncryptor (org.jasypt.encryption.pbe.StandardPBEStringEncryptor)1 Before (org.junit.Before)1