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);
}
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));
}
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();
}
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)));
}
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);
}
Aggregations