forked from eclipse-syson/syson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[639] Display properties keywords for Usage compartment element
Bug: eclipse-syson#639 Signed-off-by: Jessy Mallet <jessy.mallet@obeo.fr>
- Loading branch information
1 parent
3abcd13
commit 291099a
Showing
7 changed files
with
324 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
...nd/services/syson-services/src/test/java/org/eclipse/syson/services/LabelServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.syson.services; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.eclipse.sirius.components.core.api.IFeedbackMessageService; | ||
import org.eclipse.syson.sysml.AttributeUsage; | ||
import org.eclipse.syson.sysml.FeatureDirectionKind; | ||
import org.eclipse.syson.sysml.SysmlFactory; | ||
import org.eclipse.syson.sysml.Usage; | ||
import org.eclipse.syson.sysml.helper.LabelConstants; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Label services tests. | ||
* | ||
* @author jmallet | ||
*/ | ||
public class LabelServiceTest extends AbstractServiceTest { | ||
|
||
private LabelService labelService; | ||
|
||
@BeforeEach | ||
void beforeEach() { | ||
this.labelService = new LabelService(new IFeedbackMessageService.NoOp()); | ||
} | ||
|
||
@DisplayName("Check Usage prefix label with default properties") | ||
@Test | ||
void testUsagePrefixLabelWithDefaultProperties() { | ||
Usage usageWithNoDirection = SysmlFactory.eINSTANCE.createUsage(); | ||
|
||
assertEquals(LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithNoDirection)); | ||
} | ||
|
||
@DisplayName("Check Usage prefix label with abstract property") | ||
@Test | ||
void testUsagePrefixLabelWithAbstractProperty() { | ||
Usage usageWithNoDirection = SysmlFactory.eINSTANCE.createUsage(); | ||
|
||
usageWithNoDirection.setIsAbstract(true); | ||
assertEquals(LabelConstants.ABSTRACT + LabelConstants.SPACE + LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithNoDirection)); | ||
} | ||
|
||
@DisplayName("Check Usage prefix label with derived property") | ||
@Test | ||
void testUsagePrefixLabelWithDerivedProperty() { | ||
Usage usageWithNoDirection = SysmlFactory.eINSTANCE.createUsage(); | ||
|
||
usageWithNoDirection.setIsDerived(true); | ||
assertEquals(LabelConstants.DERIVED + LabelConstants.SPACE + LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithNoDirection)); | ||
} | ||
|
||
@DisplayName("Check Usage prefix label with end property") | ||
@Test | ||
void testUsagePrefixLabelWithEndProperty() { | ||
Usage usageWithNoDirection = SysmlFactory.eINSTANCE.createUsage(); | ||
|
||
usageWithNoDirection.setIsEnd(true); | ||
assertEquals(LabelConstants.END + LabelConstants.SPACE + LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithNoDirection)); | ||
} | ||
|
||
@DisplayName("Check Usage prefix label with readonly property") | ||
@Test | ||
void testUsagePrefixLabelWithReadOnlyProperty() { | ||
Usage usageWithNoDirection = SysmlFactory.eINSTANCE.createUsage(); | ||
|
||
usageWithNoDirection.setIsReadOnly(true); | ||
assertEquals(LabelConstants.READ_ONLY + LabelConstants.SPACE + LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithNoDirection)); | ||
} | ||
|
||
@DisplayName("Check Usage prefix label with readonly property") | ||
@Test | ||
void testUsagePrefixLabelWithVariationProperty() { | ||
Usage usageWithNoDirection = SysmlFactory.eINSTANCE.createUsage(); | ||
|
||
usageWithNoDirection.setIsVariation(true); | ||
assertEquals(LabelConstants.VARIATION + LabelConstants.SPACE + LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithNoDirection)); | ||
} | ||
|
||
@DisplayName("Check Usage prefix label with many custom properties") | ||
@Test | ||
void testUsagePrefixLabelWithManyCustomProperties() { | ||
Usage usageWithNoDirection = SysmlFactory.eINSTANCE.createUsage(); | ||
usageWithNoDirection.setIsAbstract(true); | ||
usageWithNoDirection.setIsDerived(true); | ||
usageWithNoDirection.setIsEnd(true); | ||
usageWithNoDirection.setIsReadOnly(true); | ||
usageWithNoDirection.setIsVariation(true); | ||
|
||
assertEquals(LabelConstants.ABSTRACT + LabelConstants.SPACE + LabelConstants.VARIATION + LabelConstants.SPACE + LabelConstants.READ_ONLY + LabelConstants.SPACE | ||
+ LabelConstants.DERIVED + LabelConstants.SPACE | ||
+ LabelConstants.END | ||
+ LabelConstants.SPACE + LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithNoDirection)); | ||
} | ||
|
||
@DisplayName("Check Usage prefix label with direction properties") | ||
@Test | ||
void testUsagePrefixLabelWithDirectionProperties() { | ||
Usage usageWithDirection = SysmlFactory.eINSTANCE.createUsage(); | ||
|
||
usageWithDirection.setDirection(FeatureDirectionKind.IN); | ||
assertEquals(LabelConstants.IN + LabelConstants.SPACE + LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithDirection)); | ||
|
||
usageWithDirection.setDirection(FeatureDirectionKind.OUT); | ||
assertEquals(LabelConstants.OUT + LabelConstants.SPACE + LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithDirection)); | ||
|
||
usageWithDirection.setDirection(FeatureDirectionKind.INOUT); | ||
assertEquals(LabelConstants.INOUT + LabelConstants.SPACE + LabelConstants.REF + LabelConstants.SPACE, this.labelService.getUsagePrefix(usageWithDirection)); | ||
} | ||
|
||
@DisplayName("Check AttributeUsage prefix label with default properties") | ||
@Test | ||
void testAttributeUsagePrefixLabelWithDefaultProperties() { | ||
AttributeUsage attributeUsageWithNoDirection = SysmlFactory.eINSTANCE.createAttributeUsage(); | ||
|
||
assertEquals("", this.labelService.getUsagePrefix(attributeUsageWithNoDirection)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.