Search in sources :

Example 56 with ClientModelStore

use of com.canoo.dp.impl.client.legacy.ClientModelStore in project dolphin-platform by canoo.

the class TestDolphinPlatformHttpClientConnector method testBadResponse.

@Test(expectedExceptions = DolphinRemotingException.class)
public void testBadResponse() throws DolphinRemotingException, URISyntaxException {
    PlatformClient.init(new HeadlessToolkit());
    PlatformClient.getClientConfiguration().setHttpURLConnectionFactory(new HttpURLConnectionFactory() {

        @Override
        public HttpURLConnection create(URI url) throws IOException {
            return new HttpURLConnection(url.toURL()) {

                @Override
                public void disconnect() {
                }

                @Override
                public boolean usingProxy() {
                    return false;
                }

                @Override
                public void connect() throws IOException {
                }

                @Override
                public OutputStream getOutputStream() throws IOException {
                    return new ByteArrayOutputStream();
                }
            };
        }
    });
    final ClientModelStore clientModelStore = new ClientModelStore(new DefaultModelSynchronizer(() -> null));
    final DolphinPlatformHttpClientConnector connector = new DolphinPlatformHttpClientConnector(getDummyURL(), PlatformClient.getClientConfiguration(), clientModelStore, new JsonCodec(), new SimpleExceptionHandler(), new HttpClientImpl(new Gson(), PlatformClient.getClientConfiguration()));
    final List<Command> commands = new ArrayList<>();
    commands.add(new CreateContextCommand());
    connector.transmit(commands);
}
Also used : DolphinPlatformHttpClientConnector(com.canoo.dp.impl.client.DolphinPlatformHttpClientConnector) ByteArrayOutputStream(java.io.ByteArrayOutputStream) OutputStream(java.io.OutputStream) ArrayList(java.util.ArrayList) Gson(com.google.gson.Gson) DefaultModelSynchronizer(com.canoo.dp.impl.client.legacy.DefaultModelSynchronizer) IOException(java.io.IOException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SimpleExceptionHandler(com.canoo.dp.impl.client.legacy.communication.SimpleExceptionHandler) CreateContextCommand(com.canoo.dp.impl.remoting.commands.CreateContextCommand) HttpURLConnectionFactory(com.canoo.platform.core.http.HttpURLConnectionFactory) JsonCodec(com.canoo.dp.impl.remoting.legacy.communication.JsonCodec) CreateContextCommand(com.canoo.dp.impl.remoting.commands.CreateContextCommand) Command(com.canoo.dp.impl.remoting.legacy.communication.Command) CreatePresentationModelCommand(com.canoo.dp.impl.remoting.legacy.communication.CreatePresentationModelCommand) HeadlessToolkit(com.canoo.platform.client.HeadlessToolkit) HttpClientImpl(com.canoo.dp.impl.platform.client.http.HttpClientImpl) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) Test(org.testng.annotations.Test)

Example 57 with ClientModelStore

use of com.canoo.dp.impl.client.legacy.ClientModelStore in project dolphin-platform by canoo.

the class TestDeleteAll method testWithSimpleModel.

@Test
public void testWithSimpleModel(@Mocked AbstractClientConnector connector) {
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final EventDispatcher dispatcher = createEventDispatcher(clientModelStore);
    final BeanRepository repository = createBeanRepository(clientModelStore, dispatcher);
    final BeanManager manager = createBeanManager(clientModelStore, repository, dispatcher);
    SimpleTestModel model1 = manager.create(SimpleTestModel.class);
    SimpleTestModel model2 = manager.create(SimpleTestModel.class);
    SimpleTestModel model3 = manager.create(SimpleTestModel.class);
    SimpleAnnotatedTestModel wrongModel = manager.create(SimpleAnnotatedTestModel.class);
    for (Object bean : manager.findAll(SimpleTestModel.class)) {
        repository.delete(bean);
    }
    assertThat(repository.isManaged(model1), is(false));
    assertThat(repository.isManaged(model2), is(false));
    assertThat(repository.isManaged(model3), is(false));
    assertThat(repository.isManaged(wrongModel), is(true));
    List<ClientPresentationModel> testModels = clientModelStore.findAllPresentationModelsByType("com.canoo.dolphin.client.util.SimpleTestModel");
    assertThat(testModels, hasSize(0));
}
Also used : EventDispatcher(com.canoo.dp.impl.remoting.EventDispatcher) SimpleAnnotatedTestModel(com.canoo.dolphin.client.util.SimpleAnnotatedTestModel) BeanRepository(com.canoo.dp.impl.remoting.BeanRepository) SimpleTestModel(com.canoo.dolphin.client.util.SimpleTestModel) ClientPresentationModel(com.canoo.dp.impl.client.legacy.ClientPresentationModel) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Example 58 with ClientModelStore

use of com.canoo.dp.impl.client.legacy.ClientModelStore in project dolphin-platform by canoo.

the class ClientConnectorTests method setUp.

@BeforeMethod
public void setUp() {
    ModelSynchronizer defaultModelSynchronizer = new DefaultModelSynchronizer(() -> clientConnector);
    clientModelStore = new ClientModelStore(defaultModelSynchronizer);
    clientConnector = new TestClientConnector(clientModelStore, DirectExecutor.getInstance());
    try {
        attributeChangeListener = clientModelStore.getAttributeChangeListener();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    clientConnector.connect(false);
    initLatch();
}
Also used : DefaultModelSynchronizer(com.canoo.dp.impl.client.legacy.DefaultModelSynchronizer) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) ModelSynchronizer(com.canoo.dp.impl.client.legacy.ModelSynchronizer) DefaultModelSynchronizer(com.canoo.dp.impl.client.legacy.DefaultModelSynchronizer) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 59 with ClientModelStore

use of com.canoo.dp.impl.client.legacy.ClientModelStore in project dolphin-platform by canoo.

the class TestFindAll method testWithSimpleModel.

@Test
public void testWithSimpleModel(@Mocked AbstractClientConnector connector) {
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final BeanManager manager = createBeanManager(clientModelStore);
    SimpleTestModel model1 = manager.create(SimpleTestModel.class);
    SimpleTestModel model2 = manager.create(SimpleTestModel.class);
    SimpleTestModel model3 = manager.create(SimpleTestModel.class);
    manager.create(SimpleAnnotatedTestModel.class);
    List<SimpleTestModel> models = manager.findAll(SimpleTestModel.class);
    assertThat(models, is(Arrays.asList(model1, model2, model3)));
}
Also used : SimpleTestModel(com.canoo.dolphin.client.util.SimpleTestModel) ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest) Test(org.testng.annotations.Test)

Example 60 with ClientModelStore

use of com.canoo.dp.impl.client.legacy.ClientModelStore in project dolphin-platform by canoo.

the class TestModelCreation method testWithNull.

@Test(expectedExceptions = NullPointerException.class)
public void testWithNull(@Mocked AbstractClientConnector connector) {
    final ClientModelStore clientModelStore = createClientModelStore(connector);
    final BeanManager manager = createBeanManager(clientModelStore);
    String model = manager.create(null);
}
Also used : ClientModelStore(com.canoo.dp.impl.client.legacy.ClientModelStore) BeanManager(com.canoo.platform.remoting.BeanManager) Test(org.testng.annotations.Test) AbstractDolphinBasedTest(com.canoo.dolphin.client.util.AbstractDolphinBasedTest)

Aggregations

ClientModelStore (com.canoo.dp.impl.client.legacy.ClientModelStore)97 Test (org.testng.annotations.Test)94 AbstractDolphinBasedTest (com.canoo.dolphin.client.util.AbstractDolphinBasedTest)92 BeanManager (com.canoo.platform.remoting.BeanManager)91 ClientPresentationModel (com.canoo.dp.impl.client.legacy.ClientPresentationModel)82 PresentationModel (com.canoo.dp.impl.remoting.legacy.core.PresentationModel)76 ListReferenceModel (com.canoo.dolphin.client.util.ListReferenceModel)65 BeanRepository (com.canoo.dp.impl.remoting.BeanRepository)25 EventDispatcher (com.canoo.dp.impl.remoting.EventDispatcher)25 SimpleTestModel (com.canoo.dolphin.client.util.SimpleTestModel)17 Attribute (com.canoo.dp.impl.remoting.legacy.core.Attribute)13 SimpleAnnotatedTestModel (com.canoo.dolphin.client.util.SimpleAnnotatedTestModel)5 ChildModel (com.canoo.dolphin.client.util.ChildModel)4 SingleReferenceModel (com.canoo.dolphin.client.util.SingleReferenceModel)4 DefaultModelSynchronizer (com.canoo.dp.impl.client.legacy.DefaultModelSynchronizer)4 ValueChangeEvent (com.canoo.platform.remoting.ValueChangeEvent)4 ValueChangeListener (com.canoo.platform.remoting.ValueChangeListener)4 Command (com.canoo.dp.impl.remoting.legacy.communication.Command)3 Subscription (com.canoo.platform.core.functional.Subscription)3 ComplexDataTypesModel (com.canoo.dolphin.client.util.ComplexDataTypesModel)2