org.eclipse.emf.common.util.BasicEList Java Examples

The following examples show how to use org.eclipse.emf.common.util.BasicEList. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ItemUIRegistryImplTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testStateConversionForSwitchWidgetThroughGetState() throws ItemNotFoundException {
    State colorState = new HSBType("23,42,50");

    ColorItem colorItem = new ColorItem("myItem");
    colorItem.setLabel("myItem");
    colorItem.setState(colorState);

    when(registry.getItem("myItem")).thenReturn(colorItem);

    Switch switchWidget = mock(Switch.class);
    when(switchWidget.getItem()).thenReturn("myItem");
    when(switchWidget.getMappings()).thenReturn(new BasicEList<Mapping>());

    State stateForSwitch = uiRegistry.getState(switchWidget);

    assertEquals(OnOffType.ON, stateForSwitch);
}
 
Example #2
Source File: N4JSResource.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * This is aware of warnings from the {@link N4JSStringValueConverter}.
 *
 * Issues from the parser are commonly treated as errors but here we want to create a warning.
 */
@Override
protected void addSyntaxErrors() {
	if (isValidationDisabled())
		return;
	// EList.add unnecessarily checks for uniqueness by default
	// so we use #addUnique below to save some CPU cycles for heavily broken
	// models
	BasicEList<Diagnostic> errorList = (BasicEList<Diagnostic>) getErrors();
	BasicEList<Diagnostic> warningList = (BasicEList<Diagnostic>) getWarnings();

	for (INode error : getParseResult().getSyntaxErrors()) {
		processSyntaxDiagnostic(error, diagnostic -> {
			String code = diagnostic.getCode();
			Severity severity = IssueCodes.getDefaultSeverity(code);
			if (AbstractN4JSStringValueConverter.WARN_ISSUE_CODE.equals(code)
					|| RegExLiteralConverter.ISSUE_CODE.equals(code)
					|| LegacyOctalIntValueConverter.ISSUE_CODE.equals(code)
					|| severity == Severity.WARNING) {
				warningList.addUnique(diagnostic);
			} else if (!InternalSemicolonInjectingParser.SEMICOLON_INSERTED.equals(code)) {
				errorList.addUnique(diagnostic);
			}
		});
	}
}
 
Example #3
Source File: DefaultActionPrototypeProviderTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
public void createPrototypeFromJvmModel_void() {
	JvmIdentifiableElement container = createJvmIdentifiableElementStub();
	QualifiedActionName qn = this.provider.createQualifiedActionName(container, "myfct");
	EList<JvmFormalParameter> params = new BasicEList<>();
	//
	InferredPrototype prototype = this.provider.createPrototypeFromJvmModel(this.context, qn, false, params);
	assertNotNull(prototype);
	assertEquals("myfct", prototype.getActionName().getActionName());
	assertSameJvmFormalParameters(params, prototype.getFormalParameters());
	assertEquals("", prototype.getFormalParameterTypes().toString());
	assertContainsStrings(
			prototype.getParameterTypeAlternatives(),
			"");
	assertTrue(prototype.getInferredParameterTypes().isEmpty());
}
 
Example #4
Source File: ConcreteSyntaxAwareReferenceFinder.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void findReferences(Predicate<URI> targetURIs, Resource resource, Acceptor acceptor,
		IProgressMonitor monitor) {
	// make sure data is present
	keys.getData((TargetURIs) targetURIs, new SimpleResourceAccess(resource.getResourceSet()));
	EList<EObject> astContents;
	if (resource instanceof N4JSResource) {
		// In case of N4JSResource, we search only in the AST but NOT in TModule tree!
		Script script = (Script) ((N4JSResource) resource).getContents().get(0);
		astContents = new BasicEList<>();
		astContents.add(script);
	} else {
		astContents = resource.getContents();
	}
	for (EObject content : astContents) {
		findReferences(targetURIs, content, acceptor, monitor);
	}
}
 
Example #5
Source File: ItemUIRegistryImplTest.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testStateConversionForSwitchWidgetThroughGetState() throws ItemNotFoundException {
    State colorState = new HSBType("23,42,50");

    ColorItem colorItem = new ColorItem("myItem");
    colorItem.setLabel("myItem");
    colorItem.setState(colorState);

    when(registry.getItem("myItem")).thenReturn(colorItem);

    Switch switchWidget = mock(Switch.class);
    when(switchWidget.getItem()).thenReturn("myItem");
    when(switchWidget.getMappings()).thenReturn(new BasicEList<>());

    State stateForSwitch = uiRegistry.getState(switchWidget);

    assertEquals(OnOffType.ON, stateForSwitch);
}
 
Example #6
Source File: ItemUIRegistryImpl.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public EList<Widget> getChildren(LinkableWidget w) {
    EList<Widget> widgets = null;
    if (w instanceof Group && w.getChildren().isEmpty()) {
        widgets = getDynamicGroupChildren((Group) w);
    } else {
        widgets = w.getChildren();
    }

    EList<Widget> result = new BasicEList<Widget>();
    for (Widget widget : widgets) {
        Widget resolvedWidget = resolveDefault(widget);
        if (resolvedWidget != null) {
            result.add(resolvedWidget);
        }
    }
    return result;
}
 
Example #7
Source File: UpdateConnectorDefinitionMigrationTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_migrateAfter_update_definitionVersion_in_connector() throws Exception {
    //Given
    doCallRealMethod().when(updateConnectorVersionMigration).migrateAfter(model, metamodel);
    final EList<Instance> connectorInstanceList = connectorInstanceList("id1","id2");
    final Instance oldConnectorInstance = aConnectorInstance("id1", "0.9");
    connectorInstanceList.add(oldConnectorInstance);
    when(model.getAllInstances("process.Connector")).thenReturn(connectorInstanceList);
    when(model.getAllInstances("connectorconfiguration.ConnectorConfiguration")).thenReturn(new BasicEList<Instance>());
    when(updateConnectorVersionMigration.shouldUpdateVersion("id1")).thenReturn(true);
    when(updateConnectorVersionMigration.getOldDefinitionVersion()).thenReturn("1.0");
    when(updateConnectorVersionMigration.getNewDefinitionVersion()).thenReturn("2.0");


    //When
    updateConnectorVersionMigration.migrateAfter(model, metamodel);

    //Then
    final Instance id1Connector = connectorInstanceList.get(0);
    final Instance id2Connector = connectorInstanceList.get(1);
    verify(id1Connector).set(UpdateConnectorDefinitionMigration.DEFINITION_VERSION_FEATURE_NAME, "2.0");
    verify(id2Connector, never()).set(UpdateConnectorDefinitionMigration.DEFINITION_VERSION_FEATURE_NAME, "2.0");
    verify(oldConnectorInstance, never()).set(UpdateConnectorDefinitionMigration.DEFINITION_VERSION_FEATURE_NAME, "2.0");
}
 
Example #8
Source File: ItemUIRegistryImpl.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public EList<Widget> getChildren(LinkableWidget w) {
    EList<Widget> widgets = null;
    if (w instanceof Group && w.getChildren().isEmpty()) {
        widgets = getDynamicGroupChildren((Group) w);
    } else {
        widgets = w.getChildren();
    }

    EList<Widget> result = new BasicEList<>();
    for (Widget widget : widgets) {
        Widget resolvedWidget = resolveDefault(widget);
        if (resolvedWidget != null) {
            result.add(resolvedWidget);
        }
    }
    return result;
}
 
Example #9
Source File: ItemUIRegistryImplTest.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testStateConversionForSwitchWidgetWithMappingThroughGetState() throws ItemNotFoundException {
    State colorState = new HSBType("23,42,50");

    ColorItem colorItem = new ColorItem("myItem");
    colorItem.setLabel("myItem");
    colorItem.setState(colorState);

    when(registry.getItem("myItem")).thenReturn(colorItem);

    Switch switchWidget = mock(Switch.class);
    when(switchWidget.getItem()).thenReturn("myItem");

    Mapping mapping = mock(Mapping.class);
    BasicEList<Mapping> mappings = new BasicEList<Mapping>();
    mappings.add(mapping);
    when(switchWidget.getMappings()).thenReturn(mappings);

    State stateForSwitch = uiRegistry.getState(switchWidget);

    assertEquals(colorState, stateForSwitch);
}
 
Example #10
Source File: TypesUtil.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
private static void prependContainingFeatureName(StringBuilder id, EObject container) {
	EStructuralFeature feature = container.eContainingFeature();
	if (feature != null) {
		String name;
		if (feature.isMany()) {
			Object elements = container.eContainer().eGet(feature);
			int index = 0;
			if (elements instanceof BasicEList) {
				BasicEList<?> elementList = (BasicEList<?>) elements;
				index = elementList.indexOf(container);
			}
			name = feature.getName() + index;
		} else {
			name = feature.getName();
		}
		id.insert(0, ID_SEPARATOR);
		id.insert(0, name);
	}
}
 
Example #11
Source File: ComposedMemberInfo.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
private void handleFParameters(TMember member, RuleEnvironment G) {
	EList<TFormalParameter> fpars = null;
	if (member instanceof TMethod) {
		TMethod method = (TMethod) member;
		fpars = method.getFpars();
	}
	if (member instanceof TSetter) {
		TSetter setter = (TSetter) member;
		fpars = new BasicEList<>();
		fpars.add(setter.getFpar());
	}
	if (fpars != null) {
		for (int i = 0; i < fpars.size(); i++) {
			TFormalParameter fpar = fpars.get(i);
			if (fParameters.size() <= i) {
				fParameters.add(new ComposedFParInfo());
			}
			ComposedFParInfo fpAggr = fParameters.get(i);
			Pair<TFormalParameter, RuleEnvironment> fpPair = new Pair<>(fpar, G);
			fpAggr.fpSiblings.add(fpPair);
		}
	}
}
 
Example #12
Source File: UpdateConnectorDefinitionMigrationTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_migrateAfter_update_version_in_connector_configuration() throws Exception {
    //Given
    doCallRealMethod().when(updateConnectorVersionMigration).migrateAfter(model, metamodel);
    final EList<Instance> connectorConfigInstanceList = connectorConfiguratiobInstanceList("id1", "id2");
    final Instance oldConnectorConfInstance = aConnectorConfigurationInstance("id1", "0.9");
    connectorConfigInstanceList.add(oldConnectorConfInstance);
    when(model.getAllInstances("connectorconfiguration.ConnectorConfiguration")).thenReturn(connectorConfigInstanceList);
    when(model.getAllInstances("process.Connector")).thenReturn(new BasicEList<Instance>());
    when(updateConnectorVersionMigration.shouldUpdateVersion("id1")).thenReturn(true);
    when(updateConnectorVersionMigration.getOldDefinitionVersion()).thenReturn("1.0");
    when(updateConnectorVersionMigration.getNewDefinitionVersion()).thenReturn("2.0");

    //When
    updateConnectorVersionMigration.migrateAfter(model, metamodel);

    //Then
    final Instance id1ConnectorConf = connectorConfigInstanceList.get(0);
    final Instance id2ConnectorConf = connectorConfigInstanceList.get(1);
    verify(id1ConnectorConf).set(UpdateConnectorDefinitionMigration.VERSION_FEATURE_NAME, "2.0");
    verify(id2ConnectorConf, never()).set(UpdateConnectorDefinitionMigration.VERSION_FEATURE_NAME, "2.0");
    verify(oldConnectorConfInstance, never()).set(UpdateConnectorDefinitionMigration.VERSION_FEATURE_NAME, "2.0");
}
 
Example #13
Source File: SitemapSubscriptionService.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private EList<Widget> collectWidgets(String sitemapName, String pageId) {
    EList<Widget> widgets = new BasicEList<Widget>();

    Sitemap sitemap = getSitemap(sitemapName);
    if (sitemap != null) {
        if (pageId.equals(sitemap.getName())) {
            widgets = itemUIRegistry.getChildren(sitemap);
        } else {
            Widget pageWidget = itemUIRegistry.getWidget(sitemap, pageId);
            if (pageWidget instanceof LinkableWidget) {
                widgets = itemUIRegistry.getChildren((LinkableWidget) pageWidget);
                // We add the page widget. It will help any UI to update the page title.
                widgets.add(pageWidget);
            }
        }
    }
    return widgets;
}
 
Example #14
Source File: DefaultActionPrototypeProviderTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Test
public void createPrototypeFromJvmModel_void() {
	JvmIdentifiableElement container = createJvmIdentifiableElementStub();
	QualifiedActionName qn = this.provider.createQualifiedActionName(container, "myfct");
	EList<JvmFormalParameter> params = new BasicEList<>();
	//
	InferredPrototype prototype = this.provider.createPrototypeFromJvmModel(this.context, qn, false, params);
	assertNotNull(prototype);
	assertEquals("myfct", prototype.getActionName().getActionName());
	assertSameJvmFormalParameters(params, prototype.getFormalParameters());
	assertEquals("", prototype.getFormalParameterTypes().toString());
	assertContainsStrings(
			prototype.getParameterTypeAlternatives(),
			"");
	assertTrue(prototype.getInferredParameterTypes().isEmpty());
}
 
Example #15
Source File: JvmAnnotationReferenceImplCustom.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public EList<JvmAnnotationValue> getValues() {
	EList<JvmAnnotationValue> explicitValues = getExplicitValues();
	List<JvmOperation> operations = Lists.newArrayList(getAnnotation().getDeclaredOperations());
	if (operations.size() <= explicitValues.size()) {
		return ECollections.unmodifiableEList(explicitValues);
	}
	Set<JvmOperation> seenOperations = Sets.newHashSetWithExpectedSize(operations.size());
	BasicEList<JvmAnnotationValue> result = new BasicEList<JvmAnnotationValue>(operations.size());
	for(JvmAnnotationValue value: explicitValues) {
		seenOperations.add(value.getOperation());
		result.add(value);
	}
	for(JvmOperation operation: operations) {
		if (seenOperations.add(operation)) {
			JvmAnnotationValue defaultValue = operation.getDefaultValue();
			if (defaultValue != null) {
				result.add(defaultValue);
			}
		}
	}
	return ECollections.unmodifiableEList(result);
}
 
Example #16
Source File: EObjectContentProviderTest.java    From dsl-devkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Mocks XtextEditor and XtextElementSelectionListener to return an element selection that has:
 * - given EAttribute with a specific value (AttributeValuePair)
 * - given EStructuralFeature
 * - given EOperation.
 *
 * @param attributeValuePair
 *          EAttribute with a specific value
 * @param feature
 *          the EStructuralFeature
 * @param operation
 *          the EOperation
 * @return the EClass of the "selected" element
 */
@SuppressWarnings("unchecked")
private EClass mockSelectedElement(final AttributeValuePair attributeValuePair, final EStructuralFeature feature, final EOperation operation) {
  EClass mockSelectionEClass = mock(EClass.class);
  when(mockSelectionListener.getSelectedElementType()).thenReturn(mockSelectionEClass);
  // Mockups for returning AttributeValuePair
  URI elementUri = URI.createURI("");
  when(mockSelectionListener.getSelectedElementUri()).thenReturn(elementUri);
  XtextEditor mockEditor = mock(XtextEditor.class);
  when(mockSelectionListener.getEditor()).thenReturn(mockEditor);
  IXtextDocument mockDocument = mock(IXtextDocument.class);
  when(mockEditor.getDocument()).thenReturn(mockDocument);
  when(mockDocument.<ArrayList<AttributeValuePair>> readOnly(any(IUnitOfWork.class))).thenReturn(newArrayList(attributeValuePair));
  // Mockups for returning EOperation
  BasicEList<EOperation> mockEOperationsList = new BasicEList<EOperation>();
  mockEOperationsList.add(operation);
  when(mockSelectionEClass.getEAllOperations()).thenReturn(mockEOperationsList);
  // Mockups for returning EStructuralFeature
  BasicEList<EStructuralFeature> mockEStructuralFeatureList = new BasicEList<EStructuralFeature>();
  mockEStructuralFeatureList.add(feature);
  mockEStructuralFeatureList.add(attributeValuePair.getAttribute());
  when(mockSelectionEClass.getEAllStructuralFeatures()).thenReturn(mockEStructuralFeatureList);
  return mockSelectionEClass;
}
 
Example #17
Source File: MetaModelHandler.java    From kieker with Apache License 2.0 5 votes vote down vote up
/**
 * This method checks the ports of the given model plugin against the ports of the actual plugin. If there are ports which are in the model instance, but not in
 * the "real" plugin, an exception is thrown.
 * 
 * This method should be called during the creation of an <i>AnalysisController</i> via a configuration file to find invalid (outdated) ports.
 * 
 * @param mPlugin
 *            The model instance of the plugin.
 * @param plugin
 *            The corresponding "real" plugin.
 * @throws AnalysisConfigurationException
 *             If an invalid port has been detected.
 */
public static void checkPorts(final MIPlugin mPlugin, final AbstractPlugin plugin) throws AnalysisConfigurationException {
	// Get all ports.
	final EList<MIOutputPort> mOutputPorts = mPlugin.getOutputPorts();
	final Set<String> outputPorts = new HashSet<String>();
	for (final String outputPort : plugin.getAllOutputPortNames()) {
		outputPorts.add(outputPort);
	}
	final Set<String> inputPorts = new HashSet<String>();
	for (final String inputPort : plugin.getAllInputPortNames()) {
		inputPorts.add(inputPort);
	}
	// Check whether the ports of the model plugin exist.
	for (final MIOutputPort mOutputPort : mOutputPorts) {
		if (!outputPorts.contains(mOutputPort.getName())) {
			throw new AnalysisConfigurationException("The output port '" + mOutputPort.getName() + "' of '" + mPlugin.getName() + "' (" + mPlugin.getClassname()
					+ ") does not exist.");
		}
	}
	final EList<MIInputPort> mInputPorts = (mPlugin instanceof MIFilter) ? ((MIFilter) mPlugin).getInputPorts() : new BasicEList<MIInputPort>(); // NOCS
	for (final MIInputPort mInputPort : mInputPorts) {
		if (!inputPorts.contains(mInputPort.getName())) {
			throw new AnalysisConfigurationException("The input port '" + mInputPort.getName() + "' of '" + mPlugin.getName() + "' (" + mPlugin.getClassname()
					+ ") does not exist.");
		}
	}
}
 
Example #18
Source File: GenericThingProviderMultipleBundlesTest.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
private EList<ModelThing> createModelBridge() {
    ModelBridge bridge = mock(ModelBridge.class);
    when(bridge.getId()).thenReturn(BRIDGE_UID.toString());
    when(bridge.getProperties()).thenReturn(new BasicEList<>(0));
    when(bridge.getChannels()).thenReturn(new BasicEList<>(0));

    EList<ModelThing> modelThings = createModelThing();
    when(bridge.getThings()).thenReturn(modelThings);

    BasicEList<ModelThing> result = new BasicEList<>();
    result.add(bridge);
    return result;
}
 
Example #19
Source File: ElementReferenceExpressionImpl.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public EList<Expression> getExpressions() {
	if (getReference() instanceof Operation) {
		return ArgumentSorter.getOrderedExpressions(getArguments(), (Operation) getReference());
	} else {
		return new BasicEList<Expression>();
	}
}
 
Example #20
Source File: ServiceRefPropertiesEditionComponent.java    From eip-designer with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification)
 */
public void updatePart(Notification msg) {
	super.updatePart(msg);
	if (editingPart.isVisible()) {
		ServiceRefPropertiesEditionPart basePart = (ServiceRefPropertiesEditionPart)editingPart;
		if (EipPackage.eINSTANCE.getServiceRef_Name().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(EipViewsRepository.ServiceRef.Properties.name)) {
			if (msg.getNewValue() != null) {
				basePart.setName(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
			} else {
				basePart.setName("");
			}
		}
		if (EipPackage.eINSTANCE.getServiceRef_Reference().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(EipViewsRepository.ServiceRef.Properties.reference)) {
			if (msg.getNewValue() != null) {
				basePart.setReference(EcoreUtil.convertToString(EcorePackage.Literals.EJAVA_OBJECT, msg.getNewValue()));
			} else {
				basePart.setReference("");
			}
		}
		if (EipPackage.eINSTANCE.getServiceRef_Operations().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(EipViewsRepository.ServiceRef.Properties.operations)) {
			if (msg.getNewValue() instanceof EList<?>) {
				basePart.setOperations((EList<?>)msg.getNewValue());
			} else if (msg.getNewValue() == null) {
				basePart.setOperations(new BasicEList<Object>());
			} else {
				BasicEList<Object> newValueAsList = new BasicEList<Object>();
				newValueAsList.add(msg.getNewValue());
				basePart.setOperations(newValueAsList);
			}
		}
		
		
	}
}
 
Example #21
Source File: DataProvider.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @param t Term whose subdimensions are to be determined
 * @return List of subdimensions for a certain term
 */
public EList<Term> getAllSubdimenions(Term t){
	EList<Term> toReturn = new BasicEList<Term>();
	for(Term subTerm : t.getSubclasses()) {
		toReturn.add(subTerm);
		toReturn.addAll(getAllSubdimenions(subTerm));
	}
	
	return toReturn;
	
}
 
Example #22
Source File: CreateContractCustomMigrationTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    customMigration = new CreateContractCustomMigration();
    final BasicEList<Instance> uniqueTaskEList = new BasicEList<Instance>();
    uniqueTaskEList.add(originalTaskInstance);
    when(model.getAllInstances("process.Task")).thenReturn(uniqueTaskEList);
    when(model.newInstance("process.Contract")).thenReturn(newContractInstance);
}
 
Example #23
Source File: GetAllUsersHandlerTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_retrieve_all_users_from_active_orga() {
    GetAllUsersHandler handler = spy(new GetAllUsersHandler());
    RepositoryAccessor repositoryAccessor = mock(RepositoryAccessor.class);
    OrganizationRepositoryStore repositoryStore = mock(OrganizationRepositoryStore.class);
    OrganizationFileStore fileStore = mock(OrganizationFileStore.class);
    Organization orga = mock(Organization.class);
    Users users = mock(Users.class);

    EList<User> userList = new BasicEList<>();
    userList.add(createUser("walter.bates"));
    userList.add(createUser("jean.fisher"));

    doReturn(ORGA_FILE_NAME).when(handler).getActiveOrgaFileName();
    when(repositoryAccessor.getRepositoryStore(OrganizationRepositoryStore.class)).thenReturn(repositoryStore);
    when(repositoryStore.getChild(ORGA_FILE_NAME, true)).thenReturn(fileStore);
    when(fileStore.getContent()).thenReturn(orga);
    when(orga.getUsers()).thenReturn(users);
    when(users.getUser()).thenReturn(userList);

    List<String> userNames = handler.execute(repositoryAccessor);
    assertThat(userNames).containsExactly("jean.fisher", "walter.bates"); // order matters as we want the result sorted

    when(repositoryStore.getChild(ORGA_FILE_NAME, true)).thenReturn(null);
    userNames = handler.execute(repositoryAccessor);
    assertThat(userNames).isEmpty();
}
 
Example #24
Source File: InstanceImpl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EList<Instance> getContents() {
    final EList<Instance> contents = new BasicEList<Instance>();
    for (final Slot slot : getSlots()) {
        if (slot instanceof ReferenceSlot) {
            final ReferenceSlot referenceSlot = (ReferenceSlot) slot;
            if (referenceSlot.getEReference().isContainment()) {
                contents.addAll(referenceSlot.getValues());
            }
        }
    }
    return contents;
}
 
Example #25
Source File: ItemUIRegistryImpl.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public EList<Widget> getChildren(Sitemap sitemap) {
    EList<Widget> widgets = sitemap.getChildren();

    EList<Widget> result = new BasicEList<>();
    for (Widget widget : widgets) {
        Widget resolvedWidget = resolveDefault(widget);
        if (resolvedWidget != null) {
            result.add(resolvedWidget);
        }
    }
    return result;
}
 
Example #26
Source File: ClassDiagramTests.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testArgument() {
	// given
	BasicEList<String> paramNames = new BasicEList<>(Arrays.asList("a", "b", "c", "d", "e", "f"));

	BasicEList<Type> paramTypes = new BasicEList<Type>();
	paramTypes.add(classA);
	paramTypes.addAll(primitives.getSecond());

	List<String> paramTypeNames = new ArrayList<String>();
	paramTypeNames.add("A");
	paramTypeNames.addAll(primitives.getFirst());

	Operation op = classA.createOwnedOperation("function", (EList<String>) paramNames, (EList<Type>) paramTypes);

	// when
	List<Argument> instances = new ArrayList<>();
	op.getOwnedParameters().forEach(parameter -> {
		instances.add(new Argument(parameter));
	});

	// then
	IntStream.range(0, instances.size()).forEach(i -> {
		Argument instanceArgument = instances.get(i);

		Assert.assertEquals(paramNames.get(i), instanceArgument.getName());
		Assert.assertEquals(paramTypeNames.get(i), instanceArgument.getType());
	});
}
 
Example #27
Source File: AbstractHoverTest.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns values of the given feature.
 *
 * @param model
 *          the model which the given feature belongs to, must not be {@code null}
 * @param feature
 *          the feature of the model with one of many values, must not be {@code null}
 * @return the values of the feature, never {@code null}
 */
@SuppressWarnings("unchecked")
private EList<EObject> getFeatureValues(final EObject model, final EStructuralFeature feature) {
  EList<EObject> values = new BasicEList<EObject>();
  if (feature.isMany()) {
    values.addAll((EList<EObject>) model.eGet(feature));
  } else {
    values.add((EObject) model.eGet(feature, false));
  }

  return values;
}
 
Example #28
Source File: InstanceImpl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc --> <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EList<Instance> getInverse(EReference reference) {
    final List<ReferenceSlot> slots = getReferences();
    final EList<Instance> instances = new BasicEList<Instance>();
    for (final ReferenceSlot slot : slots) {
        if (reference == slot.getEReference()) {
            instances.add(slot.getInstance());
        }
    }
    return instances;
}
 
Example #29
Source File: CheckCatalogImplCustom.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public EList<Check> getAllChecks() {
  final EList<Check> result = new BasicEList<Check>();
  result.addAll(Lists.newArrayList(Iterables.concat(this.getChecks(), Iterables.concat(Iterables.transform(this.getCategories(), //
      new Function<Category, Iterable<Check>>() {
        public Iterable<Check> apply(final Category from) {
          return from.getChecks();
        }
      })))));
  return result;
}
 
Example #30
Source File: JvmTypesBuilderTest.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testAddAllNull_1() {
  final BasicEList<String> list = new BasicEList<String>();
  final List<String> otherList = null;
  this._jvmTypesBuilder.<String>operator_add(list, otherList);
  Assert.assertTrue(list.isEmpty());
}