Skip to content

Commit f9b3e34

Browse files
eclipse-pde-botlaeubi
authored andcommitted
Perform clean code of ui/org.eclipse.pde.ui.tests
1 parent 966b668 commit f9b3e34

10 files changed

+46
-24
lines changed

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/build/properties/AbstractBuildValidationTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,9 @@ private int getIntAttribute(IMarker marker, String property) {
172172
return 0;
173173
}
174174

175-
if (value == null)
175+
if (value == null) {
176176
return 0;
177+
}
177178
return value.intValue();
178179
}
179180

@@ -185,8 +186,9 @@ private String getStringAttribute(IMarker marker, String property) {
185186
value = "";
186187
}
187188

188-
if (value == null || value.equalsIgnoreCase("\"\""))
189+
if (value == null || value.equalsIgnoreCase("\"\"")) {
189190
value = "";
191+
}
190192
return value.trim();
191193
}
192194

@@ -197,8 +199,9 @@ private String getProperty(PropertyResourceBundle propertyBundle, String propert
197199
} catch (Exception e) {
198200
value = "";
199201
}
200-
if (value == null || value.equalsIgnoreCase("\"\""))
202+
if (value == null || value.equalsIgnoreCase("\"\"")) {
201203
value = "";
204+
}
202205
return value.trim();
203206
}
204207

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/ee/EnvironmentAnalyzerDelegate.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ public class EnvironmentAnalyzerDelegate implements IExecutionEnvironmentAnalyze
3838

3939
@Override
4040
public CompatibleEnvironment[] analyze(IVMInstall vm, IProgressMonitor monitor) throws CoreException {
41-
if (!(vm instanceof IVMInstall2 vm2))
41+
if (!(vm instanceof IVMInstall2 vm2)) {
4242
return new CompatibleEnvironment[0];
43+
}
4344
ArrayList<CompatibleEnvironment> result = new ArrayList<>();
4445
String javaVersion = vm2.getJavaVersion();
4546
if (javaVersion != null) {

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/model/bundle/BundleModelTestCase.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ protected void load(boolean addListener) {
5050
try {
5151
fModel = new BundleModel(fDocument, false);
5252
fModel.load();
53-
if (!fModel.isLoaded() || !fModel.isValid())
53+
if (!fModel.isLoaded() || !fModel.isValid()) {
5454
fail("model cannot be loaded");
55+
}
5556
if (addListener) {
5657
fListener = new BundleTextChangeListener(fModel.getDocument());
5758
fModel.addModelChangedListener(fListener);

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/model/bundle/RequireBundleTestCase.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,11 @@ public void testRemoveReExport() throws Exception {
514514

515515
private static RequireBundleObject getBundle(RequireBundleHeader header, String id) {
516516
RequireBundleObject[] bundles = header.getRequiredBundles();
517-
for (RequireBundleObject bundle : bundles)
518-
if (bundle.getId().equals(id))
517+
for (RequireBundleObject bundle : bundles) {
518+
if (bundle.getId().equals(id)) {
519519
return bundle;
520+
}
521+
}
520522
return null;
521523
}
522524

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/model/xml/XMLModelTestCase.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ protected void load(boolean addListener) {
4949
try {
5050
fModel = new PluginModel(fDocument, true);
5151
fModel.load();
52-
if (!fModel.isLoaded() || !fModel.isValid())
52+
if (!fModel.isLoaded() || !fModel.isValid()) {
5353
fail("model cannot be loaded");
54+
}
5455
if (addListener) {
5556
fListener = new XMLTextChangeListener(fModel.getDocument());
5657
fModel.addModelChangedListener(fListener);
@@ -68,8 +69,9 @@ protected void setXMLContents(StringBuilder body, String newline) {
6869
sb.append(newline);
6970
sb.append("<plugin>");
7071
sb.append(newline);
71-
if (body != null)
72+
if (body != null) {
7273
sb.append(body.toString());
74+
}
7375
sb.append(newline);
7476
sb.append("</plugin>");
7577
sb.append(newline);
@@ -78,8 +80,9 @@ protected void setXMLContents(StringBuilder body, String newline) {
7880

7981
protected void reload() {
8082
TextEdit[] ops = fListener.getTextOperations();
81-
if (ops.length == 0)
83+
if (ops.length == 0) {
8284
return;
85+
}
8386
MultiTextEdit multi = new MultiTextEdit();
8487
multi.addChildren(ops);
8588
try {

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/performance/parts/AbstractSchemaPerfTest.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,17 @@ protected void setUpIterations() {
5353

5454
private void setUpSchemaFile() throws Exception, IOException {
5555
Bundle bundle = FrameworkUtil.getBundle(AbstractSchemaPerfTest.class);
56-
if (bundle == null)
56+
if (bundle == null) {
5757
throw new Exception("ERROR: Bundle uninitialized"); //$NON-NLS-1$
58+
}
5859
URL url = bundle.getEntry(F_FILENAME);
59-
if (url == null)
60+
if (url == null) {
6061
throw new Exception("ERROR: URL not found: " + F_FILENAME); //$NON-NLS-1$
62+
}
6163
String path = FileLocator.resolve(url).getPath();
62-
if ("".equals(path)) //$NON-NLS-1$
64+
if ("".equals(path)) { //$NON-NLS-1$
6365
throw new Exception("ERROR: URL unresolved: " + F_FILENAME); //$NON-NLS-1$
66+
}
6467
fXSDFile = new File(path);
6568
}
6669

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/preferences/PDEPreferencesTestCase.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ public void testPreferenceChangeListener1(){
8484
preferences.removePreferenceChangeListener(listener);
8585

8686
// Restore original value
87-
if (originalValue != key)
87+
if (originalValue != key) {
8888
preferences.put(key, originalValue);
89+
}
8990
}
9091

9192
@Test
@@ -105,8 +106,9 @@ public void testPreferenceChangeListner2(){
105106
preferences.removePreferenceChangeListener(listener);
106107

107108
// Restore original value
108-
if (originalValue != key)
109+
if (originalValue != key) {
109110
preferences.put(key, originalValue);
111+
}
110112
}
111113

112114
@Test

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/project/DynamicPluginProjectReferencesTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ public void testHopViaTargetPlatform_required() throws Exception {
7777
IBuildConfiguration[] referencedBuildConfigs = coreCommandsProject
7878
.getReferencedBuildConfigs(coreCommandsProject.getActiveBuildConfig().getName(), false);
7979
for (IBuildConfiguration reference : referencedBuildConfigs) {
80-
if (reference.getProject() == osgiProject)
80+
if (reference.getProject() == osgiProject) {
8181
return;
82+
}
8283
}
8384

8485
Assert.fail("references should include local osgi project: " + Arrays.toString(referencedBuildConfigs));
@@ -101,8 +102,9 @@ public void testHopViaTargetPlatform_imported() throws Exception {
101102
IBuildConfiguration[] referencedBuildConfigs = importingTargetBundle
102103
.getReferencedBuildConfigs(importingTargetBundle.getActiveBuildConfig().getName(), false);
103104
for (IBuildConfiguration reference : referencedBuildConfigs) {
104-
if (reference.getProject() == osgiProject)
105+
if (reference.getProject() == osgiProject) {
105106
return;
107+
}
106108
}
107109

108110
Assert.fail("references should include local osgi project: " + Arrays.toString(referencedBuildConfigs));

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/wizards/NewFeatureProjectTestCase.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,21 @@ protected String getProjectName() {
5959
}
6060

6161
private void createFeature(FeatureData fd, boolean patch, Object modelObject) throws Exception {
62-
if (fd == null)
62+
if (fd == null) {
6363
fd = DEFAULT_FEATURE_DATA;
64+
}
6465
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
6566
IPath path = Platform.getLocation();
6667
IRunnableWithProgress op;
67-
if ((patch && !(modelObject instanceof IFeatureModel)) || (!patch && modelObject != null && !(modelObject instanceof IPluginBase[])))
68+
if ((patch && !(modelObject instanceof IFeatureModel)) || (!patch && modelObject != null && !(modelObject instanceof IPluginBase[]))) {
6869
fail("Unaccepted model object passed..." + modelObject);
70+
}
6971

70-
if (patch)
72+
if (patch) {
7173
op = new CreateFeaturePatchOperation(project, path, fd, (IFeatureModel) modelObject, PDEPlugin.getActiveWorkbenchShell());
72-
else
74+
} else {
7375
op = new CreateFeatureProjectOperation(project, path, fd, (IPluginBase[]) modelObject, PDEPlugin.getActiveWorkbenchShell());
76+
}
7477
IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
7578
progressService.runInUI(progressService, op, null);
7679
}
@@ -89,9 +92,10 @@ public void testCreationFeatureProject() throws Exception {
8992
@Test
9093
public void testCreationFeaturePatch() throws Exception {
9194
IFeatureModel[] models = PDECore.getDefault().getFeatureModelManager().getModels();
92-
if (models.length == 0)
95+
if (models.length == 0) {
9396
// cant test patches if no feature models exist
9497
return;
98+
}
9599
createFeature(DEFAULT_FEATURE_DATA, true, models[0]);
96100
verifyProjectExistence();
97101
verifyFeatureNature();

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/wizards/NewSiteProjectTestCase.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ public void setUp() throws Exception {
5858
+ "<category-def name=\"new_category_1\" label=\"New Category 1\"/>" //$NON-NLS-1$
5959
+ "</site>"; //$NON-NLS-1$
6060
ByteArrayInputStream source = new ByteArrayInputStream(content.getBytes(StandardCharsets.US_ASCII));
61-
if (file.exists())
61+
if (file.exists()) {
6262
file.setContents(source, true, false, new NullProgressMonitor());
63-
else
63+
} else {
6464
file.create(source, true, new NullProgressMonitor());
65+
}
6566
project.delete(false, true, new NullProgressMonitor());
6667
}
6768
}

0 commit comments

Comments
 (0)