Skip to content

Package: EMFStoreIsLoggedInTester$1

EMFStoreIsLoggedInTester$1

nameinstructionbranchcomplexitylinemethod
doRun()
M: 22 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
{...}
M: 12 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2012 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eugen Neufeld - initial API and implementation
13: *
14: *******************************************************************************/
15:
16: package org.eclipse.emf.ecp.emfstore.internal.ui.property;
17:
18: import org.eclipse.core.expressions.PropertyTester;
19: import org.eclipse.emf.ecp.core.ECPRepository;
20: import org.eclipse.emf.ecp.emfstore.core.internal.EMFStoreProvider;
21: import org.eclipse.emf.ecp.spi.core.InternalRepository;
22: import org.eclipse.emf.emfstore.client.ESServer;
23: import org.eclipse.emf.emfstore.client.ESUsersession;
24: import org.eclipse.emf.emfstore.internal.client.model.util.EMFStoreCommandWithResult;
25:
26: /**
27: * This tests whether a user is loggedIn to a specific repository.
28: *
29: * @author Eugen Neufeld
30: */
31: public class EMFStoreIsLoggedInTester extends PropertyTester {
32:
33:         /**
34:          * {@inheritDoc}
35:          *
36:          * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[],
37:          * java.lang.Object)
38:          */
39:         @Override
40:         public boolean test(Object receiver, String property, Object[] args, final Object expectedValue) {
41:                 if (receiver instanceof ECPRepository && expectedValue instanceof Boolean) {
42:                         final ECPRepository ecpRepository = (ECPRepository) receiver;
43:                         final ESServer serverInfo = EMFStoreProvider.INSTANCE.getServerInfo((InternalRepository) ecpRepository);
44:                         final EMFStoreCommandWithResult<Boolean> command = new EMFStoreCommandWithResult<Boolean>() {
45:                                 @Override
46:                                 protected Boolean doRun() {
47:                                         final ESUsersession usersession = serverInfo.getLastUsersession();
48:•                                        final Boolean ret = new Boolean(usersession != null && usersession.isLoggedIn());
49:                                         return ret.equals(expectedValue);
50:                                 }
51:                         };
52:                         final Boolean result = command.run(false);
53:                         return result;
54:                 }
55:                 return false;
56:         }
57:
58: }