Search in sources :

Example 1 with EzyObject

use of com.tvd12.ezyfox.entity.EzyObject in project ezyfox-server by youngmonkeys.

the class EzyPluginSendResponseImplTest method test.

@Test
public void test() {
    EzyPluginContext pluginContext = mock(EzyPluginContext.class);
    EzyPlugin plugin = mock(EzyPlugin.class);
    when(pluginContext.getPlugin()).thenReturn(plugin);
    EzySimplePluginSetting pluginSetting = new EzySimplePluginSetting();
    pluginSetting.setName("test");
    when(plugin.getSetting()).thenReturn(pluginSetting);
    EzyZoneContext zoneContext = mock(EzyZoneContext.class);
    when(pluginContext.getParent()).thenReturn(zoneContext);
    EzyServerContext serverContext = mock(EzyServerContext.class);
    when(zoneContext.getParent()).thenReturn(serverContext);
    EzyPluginSendResponseImpl cmd = new EzyPluginSendResponseImpl(pluginContext);
    EzyObject data = EzyEntityFactory.newObjectBuilder().build();
    EzyAbstractSession session = spy(EzyAbstractSession.class);
    cmd.execute(data, session, false);
    cmd.execute(data, Lists.newArrayList(session), false);
}
Also used : EzyZoneContext(com.tvd12.ezyfoxserver.context.EzyZoneContext) EzyPluginSendResponseImpl(com.tvd12.ezyfoxserver.command.impl.EzyPluginSendResponseImpl) EzyAbstractSession(com.tvd12.ezyfoxserver.entity.EzyAbstractSession) EzyPluginContext(com.tvd12.ezyfoxserver.context.EzyPluginContext) EzyServerContext(com.tvd12.ezyfoxserver.context.EzyServerContext) EzyPlugin(com.tvd12.ezyfoxserver.EzyPlugin) EzyObject(com.tvd12.ezyfox.entity.EzyObject) EzySimplePluginSetting(com.tvd12.ezyfoxserver.setting.EzySimplePluginSetting) Test(org.testng.annotations.Test) BaseTest(com.tvd12.test.base.BaseTest)

Example 2 with EzyObject

use of com.tvd12.ezyfox.entity.EzyObject in project ezyfox-server by youngmonkeys.

the class EzyAbstractObjectResponse method getResponseData.

@Override
protected EzyData getResponseData() {
    EzyObject object = data != null ? marshaller.marshal(data) : newObjectBuilder().build();
    if (additionalParams != null) {
        for (Map.Entry<Object, Object> e : additionalParams.entrySet()) {
            Object skey = marshaller.marshal(e.getKey());
            Object svalue = marshaller.marshal(e.getValue());
            object.put(skey, svalue);
        }
    }
    if (excludeParamKeys != null) {
        object.removeAll(excludeParamKeys);
    }
    return object;
}
Also used : EzyObject(com.tvd12.ezyfox.entity.EzyObject) EzyObject(com.tvd12.ezyfox.entity.EzyObject) Map(java.util.Map) HashMap(java.util.HashMap)

Example 3 with EzyObject

use of com.tvd12.ezyfox.entity.EzyObject in project ezyfox-server by youngmonkeys.

the class EzyUserLoginEventImplTest method test.

@SuppressWarnings("unchecked")
@Test
public void test() {
    EzyArray data = newArrayBuilder().build();
    data.add("123.abc");
    EzyObject output2 = newObjectBuilder().append("2", "b").build();
    EzyUserLoginEvent event = new EzySimpleUserLoginEvent(null, "zone", "dungtv", "123", data);
    assert event.getData() == data;
    assert event.getUsername().equals("dungtv");
    assert event.getPassword().equals("123");
    assert event.getOutput() == null;
    event.setUsername("new login name");
    event.setPassword("new password");
    event.setOutput(output2);
    assert event.getUsername().equals("new login name");
    assert event.getPassword().equals("new password");
    assert event.getOutput() == output2;
    event.setUserProperty("id", 1);
    event.setUserProperties(EzyMapBuilder.mapBuilder().build());
    assert event.getUserProperties().size() == 1;
    event.setStreamingEnable(true);
    assert event.isStreamingEnable();
    assert event.getZoneName().equals("zone");
    event = new EzySimpleUserLoginEvent(null, null, null, null, null);
    assert event.getUsername().equals("");
    assert event.getPassword().equals("");
}
Also used : EzySimpleUserLoginEvent(com.tvd12.ezyfoxserver.event.EzySimpleUserLoginEvent) EzyArray(com.tvd12.ezyfox.entity.EzyArray) EzyUserLoginEvent(com.tvd12.ezyfoxserver.event.EzyUserLoginEvent) EzyObject(com.tvd12.ezyfox.entity.EzyObject) BaseCoreTest(com.tvd12.ezyfoxserver.testing.BaseCoreTest) Test(org.testng.annotations.Test)

Example 4 with EzyObject

use of com.tvd12.ezyfox.entity.EzyObject in project ezyfox-server-android-client by youngmonkeys.

the class EzyObjectToMap method toMap.

@SuppressWarnings({ "rawtypes", "unchecked" })
public Map toMap(EzyObject object) {
    Map answer = new HashMap<>();
    for (Object key : object.keySet()) {
        Object value = object.get(key);
        Object skey = key;
        EzyArrayToList arrayToList = EzyArrayToList.getInstance();
        if (key instanceof EzyArray)
            skey = arrayToList.toList((EzyArray) key);
        else if (key instanceof EzyObject)
            skey = toMap((EzyObject) key);
        Object svalue = value;
        if (value != null) {
            if (value instanceof EzyArray)
                svalue = arrayToList.toList((EzyArray) value);
            if (value instanceof EzyObject)
                svalue = toMap((EzyObject) value);
        }
        answer.put(skey, svalue);
    }
    return answer;
}
Also used : HashMap(java.util.HashMap) EzyArray(com.tvd12.ezyfoxserver.client.entity.EzyArray) EzyObject(com.tvd12.ezyfoxserver.client.entity.EzyObject) EzyObject(com.tvd12.ezyfoxserver.client.entity.EzyObject) Map(java.util.Map) HashMap(java.util.HashMap)

Example 5 with EzyObject

use of com.tvd12.ezyfox.entity.EzyObject in project dahlia by youngmonkeys.

the class LocalCollection method findOne.

@Override
public EzyObject findOne(EzyObject query) {
    CommandFindOne command = new CommandFindOne(store.getId(), query);
    EzyObject result = commandExecutor.execute(command);
    return result;
}
Also used : EzyObject(com.tvd12.ezyfox.entity.EzyObject) CommandFindOne(com.tvd12.dahlia.core.command.CommandFindOne)

Aggregations

EzyObject (com.tvd12.ezyfox.entity.EzyObject)37 FieldSetting (com.tvd12.dahlia.core.setting.FieldSetting)19 EzyArray (com.tvd12.ezyfox.entity.EzyArray)17 CollectionSetting (com.tvd12.dahlia.core.setting.CollectionSetting)12 Collection (com.tvd12.dahlia.core.entity.Collection)11 Record (com.tvd12.dahlia.core.entity.Record)9 CollectionStorage (com.tvd12.dahlia.core.storage.CollectionStorage)9 HashMap (java.util.HashMap)6 RecordConsumer (com.tvd12.dahlia.core.function.RecordConsumer)5 DatabaseSetting (com.tvd12.dahlia.core.setting.DatabaseSetting)5 CollectionNotFoundException (com.tvd12.dahlia.exception.CollectionNotFoundException)5 DuplicatedIdException (com.tvd12.dahlia.exception.DuplicatedIdException)5 ArrayList (java.util.ArrayList)5 CollectionExistedException (com.tvd12.dahlia.exception.CollectionExistedException)4 DatabaseExistedException (com.tvd12.dahlia.exception.DatabaseExistedException)4 FindOptions (com.tvd12.dahlia.query.FindOptions)4 CommandCount (com.tvd12.dahlia.core.command.CommandCount)3 CommandFind (com.tvd12.dahlia.core.command.CommandFind)3 CommandInsertOne (com.tvd12.dahlia.core.command.CommandInsertOne)3 FieldLongSetting (com.tvd12.dahlia.core.setting.FieldLongSetting)3