Skip to content

Commit 72b9410

Browse files
authored
Merge pull request apache#5209 from hansva/main
cleanup and metadata item fixes, apache#4969
2 parents f86d3b0 + 27de8a2 commit 72b9410

File tree

15 files changed

+103
-183
lines changed

15 files changed

+103
-183
lines changed

plugins/actions/abort/src/test/java/org/apache/hop/workflow/actions/abort/ActionAbortTest.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@
1717

1818
package org.apache.hop.workflow.actions.abort;
1919

20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
2022
import org.apache.hop.core.variables.Variables;
2123
import org.apache.hop.core.xml.XmlHandler;
2224
import org.apache.hop.workflow.action.ActionMeta;
23-
import org.junit.Assert;
24-
import org.junit.Test;
25+
import org.junit.jupiter.api.Test;
2526

26-
public class ActionAbortTest {
27+
class ActionAbortTest {
2728

2829
@Test
29-
public void testXmlRoundTrip() throws Exception {
30+
void testXmlRoundTrip() throws Exception {
3031
final String message = "This is a test message";
3132
ActionAbort action = new ActionAbort();
3233
action.setMessageAbort(message);
@@ -37,6 +38,6 @@ public void testXmlRoundTrip() throws Exception {
3738
ActionAbort action2 = new ActionAbort();
3839
action2.loadXml(XmlHandler.loadXmlString(actionXml, ActionMeta.XML_TAG), null, new Variables());
3940

40-
Assert.assertEquals(action.getMessageAbort(), action2.getMessageAbort());
41+
assertEquals(action.getMessageAbort(), action2.getMessageAbort());
4142
}
4243
}

plugins/actions/abort/src/test/java/org/apache/hop/workflow/actions/abort/WorkflowActionAbortLoadSaveTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
import java.util.Arrays;
2020
import java.util.List;
2121
import java.util.Map;
22-
import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
2322
import org.apache.hop.workflow.action.loadsave.WorkflowActionLoadSaveTestSupport;
24-
import org.junit.ClassRule;
2523

2624
public class WorkflowActionAbortLoadSaveTest
2725
extends WorkflowActionLoadSaveTestSupport<ActionAbort> {
28-
@ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
2926

3027
@Override
3128
protected Class<ActionAbort> getActionClass() {

plugins/actions/addresultfilenames/src/test/java/org/apache/hop/workflow/actions/addresultfilenames/WorkflowActionAddResultFilenamesLoadSaveTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,13 @@
1818
package org.apache.hop.workflow.actions.addresultfilenames;
1919

2020
import java.util.UUID;
21-
import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
2221
import org.apache.hop.pipeline.transforms.loadsave.validator.IFieldLoadSaveValidator;
2322
import org.apache.hop.pipeline.transforms.loadsave.validator.ListLoadSaveValidator;
2423
import org.apache.hop.workflow.action.loadsave.WorkflowActionLoadSaveTestSupport;
2524
import org.junit.Before;
26-
import org.junit.ClassRule;
2725

2826
public class WorkflowActionAddResultFilenamesLoadSaveTest
2927
extends WorkflowActionLoadSaveTestSupport<ActionAddResultFilenames> {
30-
@ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
3128

3229
@Override
3330
protected Class<ActionAddResultFilenames> getActionClass() {

plugins/actions/as400command/src/test/java/org/apache/hop/workflow/actions/as400command/ActionAs400CommandLoadSaveTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,10 @@
1919
import java.util.Arrays;
2020
import java.util.List;
2121
import java.util.Map;
22-
import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
2322
import org.apache.hop.workflow.action.loadsave.WorkflowActionLoadSaveTestSupport;
24-
import org.junit.ClassRule;
2523

2624
public class ActionAs400CommandLoadSaveTest
2725
extends WorkflowActionLoadSaveTestSupport<ActionAs400Command> {
28-
@ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
2926

3027
@Override
3128
protected Class<ActionAs400Command> getActionClass() {

plugins/actions/checkdbconnection/src/test/java/org/apache/hop/workflow/actions/checkdbconnection/ActionCheckDbConnectionsTest.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,17 @@
1818

1919
package org.apache.hop.workflow.actions.checkdbconnection;
2020

21-
import static org.junit.Assert.assertEquals;
22-
import static org.junit.Assert.assertNotNull;
23-
2421
import org.apache.hop.core.HopClientEnvironment;
2522
import org.apache.hop.core.database.DatabaseMeta;
2623
import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
2724
import org.apache.hop.workflow.action.ActionSerializationTestUtil;
28-
import org.junit.Test;
25+
import org.junit.jupiter.api.Assertions;
26+
import org.junit.jupiter.api.Test;
2927

30-
public class ActionCheckDbConnectionsTest {
28+
class ActionCheckDbConnectionsTest {
3129

3230
@Test
33-
public void testSerialization() throws Exception {
31+
void testSerialization() throws Exception {
3432
HopClientEnvironment.init();
3533
DatabaseMeta databaseMeta = new DatabaseMeta();
3634
databaseMeta.setName("unit-test-db");
@@ -42,11 +40,12 @@ public void testSerialization() throws Exception {
4240
ActionSerializationTestUtil.testSerialization(
4341
"/check-db-connections-action.xml", ActionCheckDbConnections.class, provider);
4442

45-
assertEquals(1, action.getConnections().size());
46-
assertNotNull(action.getConnections().get(0).getDatabaseMeta());
47-
assertEquals("unit-test-db", action.getConnections().get(0).getDatabaseMeta().getName());
48-
assertEquals("500", action.getConnections().get(0).getWaitTime());
49-
assertEquals(
43+
Assertions.assertEquals(1, action.getConnections().size());
44+
Assertions.assertNotNull(action.getConnections().get(0).getDatabaseMeta());
45+
Assertions.assertEquals(
46+
"unit-test-db", action.getConnections().get(0).getDatabaseMeta().getName());
47+
Assertions.assertEquals("500", action.getConnections().get(0).getWaitTime());
48+
Assertions.assertEquals(
5049
ActionCheckDbConnections.WaitTimeUnit.MILLISECOND,
5150
action.getConnections().get(0).getWaitTimeUnit());
5251
}

plugins/actions/checkfilelocked/src/test/java/org/apache/hop/workflow/actions/checkfilelocked/ActionCheckFilesLockedTest.java

+11-14
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,29 @@
1818

1919
package org.apache.hop.workflow.actions.checkfilelocked;
2020

21-
import static org.junit.Assert.assertFalse;
22-
import static org.junit.Assert.assertTrue;
23-
2421
import org.apache.hop.core.HopClientEnvironment;
2522
import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
2623
import org.apache.hop.workflow.action.ActionSerializationTestUtil;
27-
import org.junit.Assert;
28-
import org.junit.Test;
24+
import org.junit.jupiter.api.Assertions;
25+
import org.junit.jupiter.api.Test;
2926

30-
public class ActionCheckFilesLockedTest {
27+
class ActionCheckFilesLockedTest {
3128

3229
@Test
33-
public void testSerialization() throws Exception {
30+
void testSerialization() throws Exception {
3431
HopClientEnvironment.init();
3532
MemoryMetadataProvider provider = new MemoryMetadataProvider();
3633

3734
ActionCheckFilesLocked action =
3835
ActionSerializationTestUtil.testSerialization(
3936
"/check-files-locked-action.xml", ActionCheckFilesLocked.class, provider);
4037

41-
assertFalse(action.isArgFromPrevious());
42-
assertTrue(action.isIncludeSubfolders());
43-
Assert.assertEquals(2, action.getCheckedFiles().size());
44-
Assert.assertEquals("/tmp/folder1", action.getCheckedFiles().get(0).getName());
45-
Assert.assertEquals(".*\\.txt$", action.getCheckedFiles().get(0).getWildcard());
46-
Assert.assertEquals("/tmp/folder2", action.getCheckedFiles().get(1).getName());
47-
Assert.assertEquals(".*\\.zip$", action.getCheckedFiles().get(1).getWildcard());
38+
Assertions.assertFalse(action.isArgFromPrevious());
39+
Assertions.assertTrue(action.isIncludeSubfolders());
40+
Assertions.assertEquals(2, action.getCheckedFiles().size());
41+
Assertions.assertEquals("/tmp/folder1", action.getCheckedFiles().get(0).getName());
42+
Assertions.assertEquals(".*\\.txt$", action.getCheckedFiles().get(0).getWildcard());
43+
Assertions.assertEquals("/tmp/folder2", action.getCheckedFiles().get(1).getName());
44+
Assertions.assertEquals(".*\\.zip$", action.getCheckedFiles().get(1).getWildcard());
4845
}
4946
}

plugins/actions/columnsexist/src/test/java/org/apache/hop/workflow/actions/columnsexist/ActionColumnsExistTest.java

+8-9
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717

1818
package org.apache.hop.workflow.actions.columnsexist;
1919

20-
import static org.junit.Assert.assertEquals;
21-
2220
import org.apache.hop.core.HopClientEnvironment;
2321
import org.apache.hop.core.database.DatabaseMeta;
2422
import org.apache.hop.metadata.serializer.memory.MemoryMetadataProvider;
2523
import org.apache.hop.workflow.action.ActionSerializationTestUtil;
26-
import org.junit.Test;
24+
import org.junit.jupiter.api.Assertions;
25+
import org.junit.jupiter.api.Test;
2726

2827
/** Unit tests for column exist action. */
2928
public class ActionColumnsExistTest {
@@ -41,11 +40,11 @@ public void testSerialization() throws Exception {
4140
ActionSerializationTestUtil.testSerialization(
4241
"/columns-exist-action.xml", ActionColumnsExist.class, provider);
4342

44-
assertEquals("unit-test-db", action.getDatabaseMeta().getName());
45-
assertEquals("SCHEMA", action.getSchemaName());
46-
assertEquals("TABLE", action.getTableName());
47-
assertEquals(2, action.getColumns().size());
48-
assertEquals("F1", action.getColumns().get(0).getName());
49-
assertEquals("F2", action.getColumns().get(1).getName());
43+
Assertions.assertEquals("unit-test-db", action.getDatabaseMeta().getName());
44+
Assertions.assertEquals("SCHEMA", action.getSchemaName());
45+
Assertions.assertEquals("TABLE", action.getTableName());
46+
Assertions.assertEquals(2, action.getColumns().size());
47+
Assertions.assertEquals("F1", action.getColumns().get(0).getName());
48+
Assertions.assertEquals("F2", action.getColumns().get(1).getName());
5049
}
5150
}

plugins/actions/copyfiles/src/test/java/org/apache/hop/workflow/actions/copyfiles/WorkflowActionCopyFilesLoadSaveTest.java

-3
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,13 @@
2121
import java.util.List;
2222
import java.util.Map;
2323
import java.util.Random;
24-
import org.apache.hop.junit.rules.RestoreHopEngineEnvironment;
2524
import org.apache.hop.pipeline.transforms.loadsave.validator.ArrayLoadSaveValidator;
2625
import org.apache.hop.pipeline.transforms.loadsave.validator.IFieldLoadSaveValidator;
2726
import org.apache.hop.pipeline.transforms.loadsave.validator.StringLoadSaveValidator;
2827
import org.apache.hop.workflow.action.loadsave.WorkflowActionLoadSaveTestSupport;
29-
import org.junit.ClassRule;
3028

3129
public class WorkflowActionCopyFilesLoadSaveTest
3230
extends WorkflowActionLoadSaveTestSupport<ActionCopyFiles> {
33-
@ClassRule public static RestoreHopEngineEnvironment env = new RestoreHopEngineEnvironment();
3431

3532
@Override
3633
protected Class<ActionCopyFiles> getActionClass() {

plugins/actions/copyfiles/src/test/java/org/apache/hop/workflow/actions/copyfiles/WorkflowActionCopyFilesTest.java

+18-25
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
*/
1717
package org.apache.hop.workflow.actions.copyfiles;
1818

19-
import static org.junit.Assert.assertEquals;
20-
import static org.junit.Assert.assertFalse;
21-
import static org.junit.Assert.assertTrue;
2219
import static org.mockito.Mockito.any;
2320
import static org.mockito.Mockito.anyString;
2421
import static org.mockito.Mockito.atLeast;
@@ -38,22 +35,18 @@
3835
import org.apache.hop.workflow.WorkflowMeta;
3936
import org.apache.hop.workflow.engine.IWorkflowEngine;
4037
import org.apache.hop.workflow.engines.local.LocalWorkflowEngine;
41-
import org.junit.Before;
42-
import org.junit.BeforeClass;
43-
import org.junit.Test;
38+
import org.junit.jupiter.api.Assertions;
39+
import org.junit.jupiter.api.BeforeEach;
40+
import org.junit.jupiter.api.Test;
4441

45-
public class WorkflowActionCopyFilesTest {
42+
class WorkflowActionCopyFilesTest {
4643
private ActionCopyFiles entry;
4744

4845
private static final String EMPTY = "";
4946

50-
@BeforeClass
51-
public static void setUpBeforeClass() {
47+
@BeforeEach
48+
void setUp() {
5249
HopLogStore.init();
53-
}
54-
55-
@Before
56-
public void setUp() {
5750
entry = new ActionCopyFiles();
5851
IWorkflowEngine<WorkflowMeta> parentWorkflow = new LocalWorkflowEngine();
5952
entry.setParentWorkflow(parentWorkflow);
@@ -63,7 +56,7 @@ public void setUp() {
6356
}
6457

6558
@Test
66-
public void fileNotCopied() throws Exception {
59+
void fileNotCopied() throws Exception {
6760
entry.sourceFileFolder = new String[] {EMPTY};
6861
entry.destinationFileFolder = new String[] {EMPTY};
6962
entry.wildcard = new String[] {EMPTY};
@@ -76,7 +69,7 @@ public void fileNotCopied() throws Exception {
7669
}
7770

7871
@Test
79-
public void fileCopied() throws Exception {
72+
void fileCopied() throws Exception {
8073
String srcPath = "path/to/file";
8174
String destPath = "path/to/dir";
8275

@@ -90,12 +83,12 @@ public void fileCopied() throws Exception {
9083
.processFileFolder(
9184
anyString(), anyString(), anyString(), any(Workflow.class), any(Result.class));
9285
verify(entry, atLeast(1)).preprocessfilefilder(any(String[].class));
93-
assertFalse(result.getResult());
94-
assertEquals(1, result.getNrErrors());
86+
Assertions.assertFalse(result.getResult());
87+
Assertions.assertEquals(1, result.getNrErrors());
9588
}
9689

9790
@Test
98-
public void filesCopied() throws Exception {
91+
void filesCopied() throws Exception {
9992
String[] srcPath = new String[] {"path1", "path2", "path3"};
10093
String[] destPath = new String[] {"dest1", "dest2", "dest3"};
10194

@@ -108,12 +101,12 @@ public void filesCopied() throws Exception {
108101
verify(entry, times(srcPath.length))
109102
.processFileFolder(
110103
anyString(), anyString(), anyString(), any(Workflow.class), any(Result.class));
111-
assertFalse(result.getResult());
112-
assertEquals(3, result.getNrErrors());
104+
Assertions.assertFalse(result.getResult());
105+
Assertions.assertEquals(3, result.getNrErrors());
113106
}
114107

115108
@Test
116-
public void saveLoad() throws Exception {
109+
void saveLoad() throws Exception {
117110
String[] srcPath = new String[] {"EMPTY_SOURCE_URL-0-"};
118111
String[] destPath = new String[] {"EMPTY_DEST_URL-0-"};
119112

@@ -122,15 +115,15 @@ public void saveLoad() throws Exception {
122115
entry.wildcard = new String[] {EMPTY};
123116

124117
String xml = "<entry>" + entry.getXml() + "</entry>";
125-
assertTrue(xml.contains(srcPath[0]));
126-
assertTrue(xml.contains(destPath[0]));
118+
Assertions.assertTrue(xml.contains(srcPath[0]));
119+
Assertions.assertTrue(xml.contains(destPath[0]));
127120
ActionCopyFiles loadedentry = new ActionCopyFiles();
128121
InputStream is = new ByteArrayInputStream(xml.getBytes());
129122
loadedentry.loadXml(
130123
XmlHandler.getSubNode(XmlHandler.loadXmlFile(is, null, false, false), "entry"),
131124
null,
132125
new Variables());
133-
assertEquals(loadedentry.destinationFileFolder[0], destPath[0]);
134-
assertEquals(loadedentry.sourceFileFolder[0], srcPath[0]);
126+
Assertions.assertEquals(loadedentry.destinationFileFolder[0], destPath[0]);
127+
Assertions.assertEquals(loadedentry.sourceFileFolder[0], srcPath[0]);
135128
}
136129
}

ui/src/main/java/org/apache/hop/ui/core/metadata/MetadataEditor.java

+3-10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.lang.reflect.ParameterizedType;
2121
import java.lang.reflect.Type;
2222
import java.util.Objects;
23+
import lombok.Getter;
2324
import org.apache.commons.lang.StringUtils;
2425
import org.apache.hop.core.Const;
2526
import org.apache.hop.core.exception.HopException;
@@ -55,14 +56,14 @@ public abstract class MetadataEditor<T extends IHopMetadata> extends MetadataFil
5556

5657
private static final Class<?> PKG = MetadataEditorDialog.class;
5758

58-
protected HopGui hopGui;
59+
@Getter protected HopGui hopGui;
5960
protected MetadataManager<T> manager;
6061
protected T metadata;
6162

6263
protected String title;
6364
protected String toolTip;
6465
protected Image titleImage;
65-
protected Image image;
66+
@Getter protected Image image;
6667
protected boolean isChanged = false;
6768
protected String originalName;
6869

@@ -133,10 +134,6 @@ protected Button createHelpButton(final Shell shell) {
133134
return HelpUtils.createHelpButton(shell, plugin);
134135
}
135136

136-
public HopGui getHopGui() {
137-
return hopGui;
138-
}
139-
140137
public MetadataManager<T> getMetadataManager() {
141138
return manager;
142139
}
@@ -155,10 +152,6 @@ public Shell getShell() {
155152
return hopGui.getShell();
156153
}
157154

158-
public Image getImage() {
159-
return image;
160-
}
161-
162155
protected void setImage(Image image) {
163156
this.image = image;
164157
}

0 commit comments

Comments
 (0)