Compare commits
1 Commits
release/8.
...
bhe/fixbui
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5283b1d306 |
@@ -1,271 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio;
|
||||
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Collections.emptyMap;
|
||||
import static java.util.Optional.ofNullable;
|
||||
import static org.apache.ziplock.JarLocation.jarLocation;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.eclipse.osgi.container.Module;
|
||||
import org.eclipse.osgi.container.ModuleContainer;
|
||||
import org.eclipse.osgi.container.ModuleDatabase;
|
||||
import org.eclipse.osgi.internal.framework.BundleContextImpl;
|
||||
import org.eclipse.osgi.internal.framework.EquinoxBundle;
|
||||
import org.eclipse.osgi.internal.framework.EquinoxContainer;
|
||||
import org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor;
|
||||
import org.eclipse.osgi.storage.Storage;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.osgi.framework.BundleListener;
|
||||
import org.talend.core.CorePlugin;
|
||||
import org.talend.core.GlobalServiceRegister;
|
||||
import org.talend.core.IService;
|
||||
import org.talend.core.model.general.ModuleNeeded;
|
||||
import org.talend.core.model.process.INode;
|
||||
import org.talend.core.model.process.INodeConnector;
|
||||
import org.talend.core.model.process.INodeReturn;
|
||||
import org.talend.core.model.temp.ECodePart;
|
||||
import org.talend.designer.core.DesignerCoreService;
|
||||
import org.talend.designer.core.DesignerPlugin;
|
||||
import org.talend.designer.core.IDesignerCoreService;
|
||||
import org.talend.sdk.component.runtime.manager.ComponentManager;
|
||||
import org.talend.sdk.component.server.front.model.ComponentDetail;
|
||||
import org.talend.sdk.component.server.front.model.ComponentId;
|
||||
import org.talend.sdk.component.server.front.model.ComponentIndex;
|
||||
import org.talend.sdk.component.studio.service.ComponentService;
|
||||
|
||||
/**
|
||||
* Unit-tests for {@link ComponentModel}
|
||||
*/
|
||||
@Disabled
|
||||
class ComponentModelTest {
|
||||
|
||||
private static Runnable stop;
|
||||
|
||||
@BeforeAll
|
||||
static void mockOSGI() throws Exception {
|
||||
final EquinoxContainer equinoxContainer = new EquinoxContainer(new HashMap<>(), null);
|
||||
final EquinoxContainerAdaptor adaptor =
|
||||
new EquinoxContainerAdaptor(equinoxContainer, Storage.createStorage(equinoxContainer), new HashMap<>());
|
||||
final ModuleContainer moduleContainer = new ModuleContainer(adaptor, new ModuleDatabase(adaptor));
|
||||
final EquinoxBundle bundle = new EquinoxBundle(1L, "ici", moduleContainer,
|
||||
EnumSet.noneOf(Module.Settings.class), 0, equinoxContainer) {
|
||||
|
||||
@Override
|
||||
public String getSymbolicName() {
|
||||
return "test";
|
||||
}
|
||||
};
|
||||
final BundleContextImpl bundleContext = new BundleContextImpl(bundle, equinoxContainer) {
|
||||
|
||||
@Override
|
||||
public void addBundleListener(final BundleListener listener) {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBundleListener(final BundleListener listener) {
|
||||
// no-op
|
||||
}
|
||||
};
|
||||
final CorePlugin corePlugin = new CorePlugin();
|
||||
final DesignerPlugin designerPlugin = new DesignerPlugin();
|
||||
Stream.of(corePlugin, designerPlugin).forEach(p -> {
|
||||
try {
|
||||
p.start(bundleContext);
|
||||
} catch (final Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
});
|
||||
final Field instance = GlobalServiceRegister.class.getDeclaredField("instance");
|
||||
instance.setAccessible(true);
|
||||
instance.set(null, new GlobalServiceRegister() {
|
||||
|
||||
@Override
|
||||
public IService getService(final Class klass) {
|
||||
if (IDesignerCoreService.class == klass) {
|
||||
return new DesignerCoreService() {
|
||||
|
||||
@Override
|
||||
public String getPreferenceStore(final String key) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
return super.getService(klass);
|
||||
}
|
||||
});
|
||||
stop = () -> {
|
||||
try {
|
||||
try {
|
||||
corePlugin.stop(bundleContext);
|
||||
} catch (final Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
instance.set(null, null);
|
||||
} catch (final Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void unmockOSGI() {
|
||||
ofNullable(stop).ifPresent(Runnable::run);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getModuleNeeded() {
|
||||
final ComponentId id = new ComponentId("id", "family", "plugin", "group:plugin:1", "XML", "XMLInput");
|
||||
final ComponentIndex idx =
|
||||
new ComponentIndex(id, "XML Input", null, null, null, 1, Arrays.asList("Local", "File"), null, emptyMap());
|
||||
final ComponentDetail detail = new ComponentDetail(id, "XML Input", null, "Processor", 1, emptyList(), null,
|
||||
emptyList(), emptyList(), emptyList(), null);
|
||||
final ComponentModel componentModel = new ComponentModel(idx, detail) {
|
||||
|
||||
@Override
|
||||
protected ComponentService.Dependencies getDependencies() {
|
||||
return new ComponentService(s -> s.startsWith("org.talend.sdk.component:component-runtime-manager:")
|
||||
? jarLocation(ComponentManager.class)
|
||||
: null).getDependencies();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean hasTcomp0Component(final INode iNode) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
final List<ModuleNeeded> modulesNeeded = componentModel.getModulesNeeded();
|
||||
assertEquals(19, modulesNeeded.size());
|
||||
// just assert a few
|
||||
assertTrue(modulesNeeded.stream().anyMatch(m -> m.getModuleName().startsWith("component-runtime-manager")));
|
||||
assertTrue(modulesNeeded.stream().anyMatch(m -> m.getModuleName().startsWith("component-runtime-impl")));
|
||||
assertTrue(modulesNeeded.stream().anyMatch(m -> m.getModuleName().startsWith("component-runtime-di")));
|
||||
assertTrue(modulesNeeded.stream().anyMatch(m -> m.getModuleName().startsWith("xbean-reflect")));
|
||||
assertTrue(modulesNeeded.stream().anyMatch(m -> "plugin-1.jar".equals(m.getModuleName())));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetOriginalFamilyName() {
|
||||
String expectedFamilyName = "Local/XML|File/XML";
|
||||
|
||||
ComponentId id = new ComponentId("id", "family", "plugin", "plugin", "XML", "XMLInput");
|
||||
ComponentIndex idx =
|
||||
new ComponentIndex(id, "XML Input", null, null, null, 1, Arrays.asList("Local", "File"), null, emptyMap());
|
||||
ComponentDetail detail = new ComponentDetail(id, "XML Input", null, "Processor", 1, emptyList(), null,
|
||||
emptyList(), emptyList(), emptyList(), null);
|
||||
ComponentModel componentModel = new ComponentModel(idx, detail);
|
||||
|
||||
assertEquals(expectedFamilyName, componentModel.getOriginalFamilyName());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetLongName() {
|
||||
String expectedName = "XML Input";
|
||||
|
||||
ComponentId id = new ComponentId("id", "family", "plugin", "plugin", "XML", "XMLInput");
|
||||
ComponentIndex idx =
|
||||
new ComponentIndex(id, "XML Input", null, null, null, 1, Arrays.asList("Local", "File"), null, emptyMap());
|
||||
ComponentDetail detail = new ComponentDetail(id, "XML Input", null, "Processor", 1, emptyList(), null,
|
||||
emptyList(), emptyList(), emptyList(), null);
|
||||
ComponentModel componentModel = new ComponentModel(idx, detail);
|
||||
|
||||
assertEquals(expectedName, componentModel.getLongName());
|
||||
}
|
||||
|
||||
@Disabled("Cannot be tested as CorePlugin is null")
|
||||
@Test
|
||||
void testCreateConnectors() {
|
||||
|
||||
ComponentId id = new ComponentId("id", "family", "plugin", "plugin", "XML", "XMLInput");
|
||||
ComponentIndex idx =
|
||||
new ComponentIndex(id, "XML Input", null, null, null, 1, Arrays.asList("Local", "File"), null, emptyMap());
|
||||
ComponentDetail detail = new ComponentDetail(id, "XML Input", null, "Processor", 1, emptyList(), null,
|
||||
emptyList(), emptyList(), emptyList(), null);
|
||||
ComponentModel componentModel = new ComponentModel(idx, detail);
|
||||
|
||||
List<? extends INodeConnector> connectors = componentModel.createConnectors(null);
|
||||
assertEquals(22, connectors.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreateReturns() {
|
||||
|
||||
ComponentId id = new ComponentId("id", "family", "plugin", "plugin", "XML", "XMLInput");
|
||||
ComponentIndex idx =
|
||||
new ComponentIndex(id, "XML Input", null, null, null, 1, Arrays.asList("Local", "File"), null, emptyMap());
|
||||
ComponentDetail detail = new ComponentDetail(id, "XML Input", null, "Processor", 1, emptyList(), null,
|
||||
emptyList(), emptyList(), emptyList(), null);
|
||||
ComponentModel componentModel = new ComponentModel(idx, detail);
|
||||
|
||||
List<? extends INodeReturn> returnVariables = componentModel.createReturns(null);
|
||||
assertEquals(2, returnVariables.size());
|
||||
INodeReturn errorMessage = returnVariables.get(0);
|
||||
assertEquals("Error Message", errorMessage.getDisplayName());
|
||||
assertEquals("!!!NodeReturn.Availability.AFTER!!!", errorMessage.getAvailability());
|
||||
assertEquals("String", errorMessage.getType());
|
||||
INodeReturn numberLines = returnVariables.get(1);
|
||||
assertEquals("Number of line", numberLines.getDisplayName());
|
||||
assertEquals("!!!NodeReturn.Availability.AFTER!!!", numberLines.getAvailability());
|
||||
assertEquals("id_Integer", numberLines.getType());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAvailableProcessorCodeParts() {
|
||||
|
||||
ComponentId id = new ComponentId("id", "family", "plugin", "plugin", "XML", "XMLInput");
|
||||
ComponentIndex idx =
|
||||
new ComponentIndex(id, "XML Input", null, null, null, 1, Arrays.asList("Local", "File"), null, emptyMap());
|
||||
ComponentDetail detail = new ComponentDetail(id, "XML Input", null, "Processor", 1, emptyList(), null,
|
||||
emptyList(), emptyList(), emptyList(), null);
|
||||
ComponentModel componentModel = new ComponentModel(idx, detail);
|
||||
|
||||
List<ECodePart> codeParts = componentModel.getAvailableCodeParts();
|
||||
assertEquals(4, codeParts.size());
|
||||
assertTrue(codeParts.contains(ECodePart.BEGIN));
|
||||
assertTrue(codeParts.contains(ECodePart.MAIN));
|
||||
assertTrue(codeParts.contains(ECodePart.FINALLY));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetAvailableInputCodeParts() {
|
||||
|
||||
ComponentId id = new ComponentId("id", "family", "plugin", "plugin", "XML", "XMLInput");
|
||||
ComponentIndex idx =
|
||||
new ComponentIndex(id, "XML Input", null, null, null, 1, Arrays.asList("Local", "File"), null, emptyMap());
|
||||
ComponentDetail detail = new ComponentDetail(id, "XML Input", null, "Input", 1, emptyList(), null, emptyList(),
|
||||
emptyList(), emptyList(), null);
|
||||
ComponentModel componentModel = new ComponentModel(idx, detail);
|
||||
|
||||
List<ECodePart> codeParts = componentModel.getAvailableCodeParts();
|
||||
assertEquals(3, codeParts.size());
|
||||
assertTrue(codeParts.contains(ECodePart.BEGIN));
|
||||
assertTrue(codeParts.contains(ECodePart.END));
|
||||
assertTrue(codeParts.contains(ECodePart.FINALLY));
|
||||
}
|
||||
}
|
||||
@@ -1,320 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio;
|
||||
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static org.apache.xbean.asm9.ClassWriter.COMPUTE_FRAMES;
|
||||
import static org.apache.xbean.asm9.Opcodes.ACC_PUBLIC;
|
||||
import static org.apache.xbean.asm9.Opcodes.ACC_SUPER;
|
||||
import static org.apache.xbean.asm9.Opcodes.ALOAD;
|
||||
import static org.apache.xbean.asm9.Opcodes.ARETURN;
|
||||
import static org.apache.xbean.asm9.Opcodes.DUP;
|
||||
import static org.apache.xbean.asm9.Opcodes.INVOKESPECIAL;
|
||||
import static org.apache.xbean.asm9.Opcodes.NEW;
|
||||
import static org.apache.xbean.asm9.Opcodes.RETURN;
|
||||
import static org.apache.xbean.asm9.Opcodes.V1_8;
|
||||
import static org.apache.ziplock.JarLocation.jarLocation;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.talend.sdk.component.server.front.model.ErrorDictionary.ICON_MISSING;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.ConnectException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.jar.JarOutputStream;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.xbean.asm9.AnnotationVisitor;
|
||||
import org.apache.xbean.asm9.ClassWriter;
|
||||
import org.apache.xbean.asm9.MethodVisitor;
|
||||
import org.apache.xbean.asm9.Type;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.talend.sdk.component.api.processor.ElementListener;
|
||||
import org.talend.sdk.component.api.processor.Processor;
|
||||
import org.talend.sdk.component.api.service.Action;
|
||||
import org.talend.sdk.component.api.service.Service;
|
||||
import org.talend.sdk.component.server.front.model.ComponentDetailList;
|
||||
import org.talend.sdk.component.server.front.model.ComponentIndices;
|
||||
import org.talend.sdk.component.server.front.model.ConfigTypeNodes;
|
||||
import org.talend.sdk.component.studio.mvn.Mvn;
|
||||
import org.talend.sdk.component.studio.util.TaCoKitConst;
|
||||
import org.talend.sdk.component.studio.websocket.WebSocketClient;
|
||||
|
||||
class ServerManagerTest {
|
||||
|
||||
@BeforeEach
|
||||
void before(@TempDir final File folder) {
|
||||
createM2(folder);
|
||||
System.setProperty("component.java.m2", folder.getAbsolutePath());
|
||||
System.setProperty("talend.component.server.component.coordinates", "test:test-component:1.0");
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void reset() {
|
||||
System.clearProperty("component.java.m2");
|
||||
System.clearProperty("talend.component.server.component.coordinates");
|
||||
}
|
||||
|
||||
@Disabled
|
||||
@Test
|
||||
void startServer() throws Exception {
|
||||
int port;
|
||||
final Thread thread = Thread.currentThread();
|
||||
final ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
|
||||
try (URLClassLoader buildLoader = new URLClassLoader(new URL[0], oldLoader) {
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(final String name) {
|
||||
if (("META-INF/maven/" + GAV.INSTANCE.getGroupId() + "/" + GAV.INSTANCE.getArtifactId() + "/pom.properties").equals(name)) {
|
||||
return new ByteArrayInputStream(
|
||||
("version = " + System.getProperty("test.version")).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return super.getResourceAsStream(name);
|
||||
}
|
||||
}; ProcessManager mgr = new ProcessManager(GAV.INSTANCE.getGroupId(), gav -> {
|
||||
final String normalizedGav = Mvn.locationToMvn(gav);
|
||||
final String[] segments = normalizedGav.substring(normalizedGav.lastIndexOf('!') + 1).split("/");
|
||||
if (segments[1].startsWith("component-")) {
|
||||
// try in the project
|
||||
final File[] root = jarLocation(ServerManagerTest.class).getParentFile().getParentFile().getParentFile()
|
||||
.listFiles((dir, name) -> name.equals(segments[1]));
|
||||
if (root != null && root.length == 1) {
|
||||
final File[] jar = new File(root[0], "target").listFiles(
|
||||
(dir, name) -> name.startsWith(segments[1]) && name.endsWith(".jar") && !name.contains("-source")
|
||||
&& !name.contains("-model") && !name.contains("-fat") && !name.contains("-javadoc"));
|
||||
if (jar != null && jar.length == 1) {
|
||||
return jar[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
final File file = new File(
|
||||
System.getProperty("test.m2.repository", System.getProperty("user.home") + "/.m2/repository"),
|
||||
segments[0].replace('.', '/') + '/' + segments[1] + '/' + segments[2] + '/' + segments[1] + '-' + segments[2]
|
||||
+ ".jar");
|
||||
assertTrue(file.exists(), file.getAbsolutePath());
|
||||
return file;
|
||||
})) {
|
||||
thread.setContextClassLoader(buildLoader);
|
||||
mgr.start();
|
||||
mgr.waitForServer(() -> {
|
||||
});
|
||||
port = mgr.getPort();
|
||||
assertTrue(isStarted(port));
|
||||
assertClient(port);
|
||||
} finally {
|
||||
thread.setContextClassLoader(oldLoader);
|
||||
}
|
||||
assertFalse(isStarted(port));
|
||||
}
|
||||
|
||||
private void createM2(final File root) {
|
||||
final File jar = new File(root, "test/test-component/1.0/test-component-1.0.jar");
|
||||
jar.getParentFile().mkdirs();
|
||||
try {
|
||||
new PluginGenerator().createPlugin(jar, "my-component");
|
||||
} catch (final IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertClient(final int port) {
|
||||
try (WebSocketClient client = new WebSocketClient("ws://", String.valueOf(port), "/websocket/v1", 600000)) {
|
||||
// we loop since we reuse the same session so we must ensure this reuse works
|
||||
for (int i = 0; i < 2; i++) {
|
||||
// simple endpoint
|
||||
final ComponentIndices indices = client.v1().component().getIndex("en");
|
||||
assertEquals(2, indices.getComponents().size());
|
||||
}
|
||||
{
|
||||
// path params, ensure we can change it through the same session usage
|
||||
final ComponentDetailList proc1 = client.v1().component().getDetail("en",
|
||||
new String[] { "dGVzdC1jb21wb25lbnQjY29tcCNwcm9jMQ" });
|
||||
assertEquals(1, proc1.getDetails().size());
|
||||
assertEquals("proc1", proc1.getDetails().get(0).getDisplayName());
|
||||
final ComponentDetailList proc2 = client.v1().component().getDetail("en",
|
||||
new String[] { "dGVzdC1jb21wb25lbnQjY29tcCNwcm9jMg" });
|
||||
assertEquals(1, proc2.getDetails().size());
|
||||
assertEquals("proc2", proc2.getDetails().get(0).getDisplayName());
|
||||
}
|
||||
// post endpoint, todo: enrich with real returned/configured data to make the
|
||||
// test more relevant
|
||||
for (int i = 0; i < 2; i++) {
|
||||
final String result = client.v1().action().execute(String.class, "proc", "user", "my-componentAction",
|
||||
new HashMap<>());
|
||||
assertEquals("{}", result);
|
||||
}
|
||||
{
|
||||
final ConfigTypeNodes repositoryModel = client.v1().configurationType().getRepositoryModel();
|
||||
assertTrue(repositoryModel.getNodes().isEmpty());
|
||||
}
|
||||
assertIcons(client, "dGVzdC1jb21wb25lbnQjY29tcCNwcm9jMQ", "Y29tcA");
|
||||
}
|
||||
}
|
||||
|
||||
private void assertIcons(final WebSocketClient client, final String compId, final String familyId) {
|
||||
final WebSocketClient.V1Component component = client.v1().component();
|
||||
try {
|
||||
component.icon(compId);
|
||||
} catch (final WebSocketClient.ClientException ce) {
|
||||
assertNotNull(ce.getErrorPayload());
|
||||
assertEquals(ICON_MISSING, ce.getErrorPayload().getCode());
|
||||
assertEquals("No icon for identifier: " + compId, ce.getErrorPayload().getDescription());
|
||||
}
|
||||
try {
|
||||
component.familyIcon(familyId);
|
||||
} catch (final WebSocketClient.ClientException ce) {
|
||||
assertNotNull(ce.getErrorPayload());
|
||||
assertEquals(ICON_MISSING, ce.getErrorPayload().getCode());
|
||||
assertEquals("No icon for family identifier: " + familyId, ce.getErrorPayload().getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isStarted(final int port) throws IOException {
|
||||
final URL url = new URL("http://" + TaCoKitConst.DEFAULT_LOCALHOST + ":" + port + "/api/v1/component/index");
|
||||
InputStream stream = null;
|
||||
try {
|
||||
stream = url.openStream();
|
||||
final String content = IOUtils.toString(stream, StandardCharsets.UTF_8.name());
|
||||
return content.contains("{\"components\":[");
|
||||
} catch (final ConnectException ioe) {
|
||||
return false;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(stream);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PluginGenerator {
|
||||
|
||||
private String toPackage(final String container) {
|
||||
return "org.talend.test.generated." + container.replace(".jar", "");
|
||||
}
|
||||
|
||||
private void createPlugin(final File jar, final String name, final String... deps) throws IOException {
|
||||
try (JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(jar))) {
|
||||
addDependencies(outputStream, deps);
|
||||
// write the classes
|
||||
final String packageName = toPackage(name).replace(".", "/");
|
||||
outputStream.write(createProcessor("1", outputStream, packageName));
|
||||
outputStream.write(createProcessor("2", outputStream, packageName));
|
||||
outputStream.write(createModel(outputStream, packageName));
|
||||
outputStream.write(createService(outputStream, packageName, name));
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] createService(final JarOutputStream outputStream, final String packageName, final String name)
|
||||
throws IOException {
|
||||
final String className = packageName + "/AService.class";
|
||||
outputStream.putNextEntry(new ZipEntry(className));
|
||||
final ClassWriter writer = new ClassWriter(COMPUTE_FRAMES);
|
||||
writer.visitAnnotation(Type.getDescriptor(Service.class), true).visitEnd();
|
||||
writer.visit(V1_8, ACC_PUBLIC + ACC_SUPER, className.substring(0, className.length() - ".class".length()), null,
|
||||
Type.getInternalName(Object.class), null);
|
||||
writer.visitSource(className.replace(".class", ".java"), null);
|
||||
addConstructor(writer);
|
||||
final MethodVisitor action = writer.visitMethod(ACC_PUBLIC, "doAction",
|
||||
"(L" + packageName + "/AModel;)L" + packageName + "/AModel;", null, new String[0]);
|
||||
final AnnotationVisitor actionAnnotation = action.visitAnnotation(Type.getDescriptor(Action.class), true);
|
||||
actionAnnotation.visit("family", "proc");
|
||||
actionAnnotation.visit("value", name + "Action");
|
||||
actionAnnotation.visitEnd();
|
||||
action.visitCode();
|
||||
action.visitTypeInsn(NEW, packageName + "/AModel");
|
||||
action.visitInsn(DUP);
|
||||
action.visitMethodInsn(INVOKESPECIAL, packageName + "/AModel", "<init>", "()V", false);
|
||||
action.visitInsn(ARETURN);
|
||||
action.visitInsn(ARETURN);
|
||||
action.visitMaxs(1, 1);
|
||||
action.visitEnd();
|
||||
writer.visitEnd();
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
private byte[] createModel(final JarOutputStream outputStream, final String packageName) throws IOException {
|
||||
final String className = packageName + "/AModel.class";
|
||||
outputStream.putNextEntry(new ZipEntry(className));
|
||||
final ClassWriter writer = new ClassWriter(COMPUTE_FRAMES);
|
||||
writer.visit(V1_8, ACC_PUBLIC + ACC_SUPER, className.substring(0, className.length() - ".class".length()), null,
|
||||
Type.getInternalName(Object.class), null);
|
||||
writer.visitSource(className.replace(".class", ".java"), null);
|
||||
addConstructor(writer);
|
||||
// no real content (fields/methods) for now
|
||||
writer.visitEnd();
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
private byte[] createProcessor(final String id, final JarOutputStream outputStream, final String packageName)
|
||||
throws IOException {
|
||||
final String className = packageName + "/AProcessor" + id + ".class";
|
||||
outputStream.putNextEntry(new ZipEntry(className));
|
||||
final ClassWriter writer = new ClassWriter(COMPUTE_FRAMES);
|
||||
final AnnotationVisitor processorAnnotation = writer.visitAnnotation(Type.getDescriptor(Processor.class), true);
|
||||
processorAnnotation.visit("family", "comp");
|
||||
processorAnnotation.visit("name", "proc" + id);
|
||||
processorAnnotation.visitEnd();
|
||||
writer.visit(V1_8, ACC_PUBLIC + ACC_SUPER, className.substring(0, className.length() - ".class".length()), null,
|
||||
Type.getInternalName(Object.class), new String[] { Serializable.class.getName().replace(".", "/") });
|
||||
writer.visitSource(className.replace(".class", ".java"), null);
|
||||
addConstructor(writer);
|
||||
// generate a processor
|
||||
final MethodVisitor emitMethod = writer.visitMethod(ACC_PUBLIC, "emit",
|
||||
"(L" + packageName + "/AModel;)L" + packageName + "/AModel;", null, new String[0]);
|
||||
emitMethod.visitAnnotation(Type.getDescriptor(ElementListener.class), true).visitEnd();
|
||||
emitMethod.visitCode();
|
||||
emitMethod.visitTypeInsn(NEW, packageName + "/AModel");
|
||||
emitMethod.visitInsn(DUP);
|
||||
emitMethod.visitMethodInsn(INVOKESPECIAL, packageName + "/AModel", "<init>", "()V", false);
|
||||
emitMethod.visitInsn(ARETURN);
|
||||
emitMethod.visitInsn(ARETURN);
|
||||
emitMethod.visitMaxs(1, 1);
|
||||
emitMethod.visitEnd();
|
||||
writer.visitEnd();
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
private void addDependencies(final JarOutputStream outputStream, final String[] deps) throws IOException {
|
||||
// start by writing the dependencies file
|
||||
outputStream.putNextEntry(new ZipEntry("TALEND-INF/dependencies.txt"));
|
||||
outputStream.write("The following files have been resolved:\n".getBytes(StandardCharsets.UTF_8));
|
||||
outputStream.write(Stream.of(deps).collect(joining("\n")).getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
private void addConstructor(final ClassWriter writer) {
|
||||
final MethodVisitor constructor = writer.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
|
||||
constructor.visitCode();
|
||||
constructor.visitVarInsn(ALOAD, 0);
|
||||
constructor.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
|
||||
constructor.visitInsn(RETURN);
|
||||
constructor.visitMaxs(1, 1);
|
||||
constructor.visitEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio.debounce;
|
||||
|
||||
import static java.lang.Thread.sleep;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class DebounceManagerTest {
|
||||
|
||||
@Test
|
||||
void debounce() throws InterruptedException {
|
||||
try (final DebounceManager manager = new DebounceManager()) {
|
||||
final DebouncedAction action = manager.createAction();
|
||||
final Collection<Long> timestamps = new ArrayList<>();
|
||||
action.debounce(() -> timestamps.add(System.nanoTime()), 1000);
|
||||
sleep(1500);
|
||||
assertEquals(1, timestamps.size());
|
||||
|
||||
// execute only once
|
||||
sleep(1500);
|
||||
assertEquals(1, timestamps.size());
|
||||
|
||||
// can be reused
|
||||
timestamps.clear();
|
||||
action.debounce(() -> timestamps.add(System.nanoTime()), 1000);
|
||||
sleep(1500);
|
||||
assertEquals(1, timestamps.size());
|
||||
|
||||
// can be updated
|
||||
timestamps.clear();
|
||||
final long start = System.nanoTime();
|
||||
action.debounce(() -> timestamps.add(0L), 1000);
|
||||
sleep(500);
|
||||
action.debounce(() -> timestamps.add(System.nanoTime()), 1000);
|
||||
sleep(1300);
|
||||
assertEquals(1, timestamps.size());
|
||||
final long waitDuration = timestamps.iterator().next() - start;
|
||||
// 1s after the last update which happens after 500ms
|
||||
assertEquals(TimeUnit.NANOSECONDS.toMillis(waitDuration), 1500, 100);
|
||||
|
||||
// ensure we can start an action and close the manager without errors
|
||||
action.debounce(() -> timestamps.add(System.nanoTime()), 10000);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio.lang;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.TestInfo;
|
||||
import org.talend.sdk.component.junit.base.junit5.TemporaryFolder;
|
||||
import org.talend.sdk.component.junit.base.junit5.WithTemporaryFolder;
|
||||
|
||||
@WithTemporaryFolder
|
||||
class LocalLockTest {
|
||||
|
||||
@Test
|
||||
void run(final TestInfo info, final TemporaryFolder folder) throws InterruptedException, IOException {
|
||||
final File lockFile = folder.newFile(info.getTestMethod().get().getName());
|
||||
{ // ensure it works "empty"
|
||||
final Lock lock1 = new LocalLock(lockFile, null);
|
||||
lock1.lock();
|
||||
lock1.unlock();
|
||||
}
|
||||
{ // now ensure it works concurrently
|
||||
final Lock lock1 = new LocalLock(lockFile, null);
|
||||
final Lock lock2 = new LocalLock(lockFile, null);
|
||||
lock1.lock();
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
new Thread(() -> {
|
||||
lock2.lock();
|
||||
latch.countDown();
|
||||
}).start();
|
||||
assertFalse(latch.await(3, SECONDS));
|
||||
lock1.unlock();
|
||||
assertTrue(latch.await(1, SECONDS));
|
||||
lock2.unlock();
|
||||
// ensure we can call unlock N times
|
||||
IntStream.range(0, 5).forEach(i -> lock2.unlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.sdk.component.studio.lang;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class StringsTest {
|
||||
|
||||
@Test
|
||||
public void testRequireNonEmpty() {
|
||||
final String expected = "some string";
|
||||
final String actual = Strings.requireNonEmpty(expected);
|
||||
Assertions.assertEquals(expected, actual);
|
||||
IllegalArgumentException e = Assertions.assertThrows(IllegalArgumentException.class, () -> Strings.requireNonEmpty(""));
|
||||
Assertions.assertEquals("String arg should not be empty", e.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveQuotes() {
|
||||
Assertions.assertEquals("some string", Strings.removeQuotes("\"some string\""));
|
||||
Assertions.assertEquals("some\"inner\" string", Strings.removeQuotes("\"some\"inner\" string\""));
|
||||
Assertions.assertEquals("\"some string", Strings.removeQuotes("\"some string"));
|
||||
Assertions.assertEquals("some string\"", Strings.removeQuotes("some string\""));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,200 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.sdk.component.studio.model.action.update;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.core.model.process.IElement;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.sdk.component.studio.model.parameter.ButtonParameter;
|
||||
import org.talend.sdk.component.studio.model.parameter.CheckElementParameter;
|
||||
import org.talend.sdk.component.studio.model.parameter.TaCoKitElementParameter;
|
||||
import org.talend.sdk.component.studio.model.parameter.TableElementParameter;
|
||||
import org.talend.sdk.component.studio.model.parameter.TextElementParameter;
|
||||
|
||||
public class UpdateCommandTest {
|
||||
|
||||
public void testOnResultFireCalled() {
|
||||
final ButtonParameterMock buttonMock = new ButtonParameterMock(null);
|
||||
final UpdateCommand command = new UpdateCommand(null, "conf", Collections.emptyMap(), buttonMock);
|
||||
command.onResult(new HashMap<>());
|
||||
Assertions.assertTrue(buttonMock.firePropertyChangeCalled());
|
||||
}
|
||||
|
||||
public void testOnResultListOption() {
|
||||
final List<Map<String, Object>> expectedValue = new ArrayList<Map<String, Object>>();
|
||||
final Map<String, Object> row1 = new HashMap<>();
|
||||
row1.put("conf.updatableConfig.table[].check", true);
|
||||
row1.put("conf.updatableConfig.table[].number", "1");
|
||||
row1.put("conf.updatableConfig.table[].operator", "GREATER");
|
||||
row1.put("conf.updatableConfig.table[].strColumn", "Talend");
|
||||
expectedValue.add(row1);
|
||||
final Map<String, Object> row2 = new HashMap<>();
|
||||
row2.put("conf.updatableConfig.table[].check", false);
|
||||
row2.put("conf.updatableConfig.table[].number", "2");
|
||||
row2.put("conf.updatableConfig.table[].operator", "LESS");
|
||||
row2.put("conf.updatableConfig.table[].strColumn", "The best");
|
||||
expectedValue.add(row2);
|
||||
|
||||
final ButtonParameter button = new ButtonParameter(null);
|
||||
|
||||
final List<IElementParameter> columns = new ArrayList<>();
|
||||
final TaCoKitElementParameter column1 = new TaCoKitElementParameter(null);
|
||||
column1.setFieldType(EParameterFieldType.CHECK);
|
||||
column1.setName("conf.updatableConfig.table[].check");
|
||||
columns.add(column1);
|
||||
final TaCoKitElementParameter column2 = new TaCoKitElementParameter(null);
|
||||
column2.setFieldType(EParameterFieldType.TEXT);
|
||||
column2.setName("conf.updatableConfig.table[].number");
|
||||
columns.add(column2);
|
||||
final TaCoKitElementParameter column3 = new TaCoKitElementParameter(null);
|
||||
column3.setFieldType(EParameterFieldType.CLOSED_LIST);
|
||||
column3.setName("conf.updatableConfig.table[].operator");
|
||||
columns.add(column3);
|
||||
final TaCoKitElementParameter column4 = new TaCoKitElementParameter(null);
|
||||
column4.setFieldType(EParameterFieldType.TEXT);
|
||||
column4.setName("conf.updatableConfig.table[].strColumn");
|
||||
columns.add(column4);
|
||||
|
||||
final TableElementParameter table = new TableElementParameter(null, columns);
|
||||
table.setName("conf.updatableConfig.table");
|
||||
table.setFieldType(EParameterFieldType.TABLE);
|
||||
|
||||
final UpdateCommand command = new UpdateCommand(null, "conf.updatableConfig", Collections.singletonMap(table.getName(), table), button);
|
||||
|
||||
final Map<String, Object> actionResult = new HashMap<>();
|
||||
final List<Map<String, Object>> tableValue = new ArrayList<>();
|
||||
final Map<String, Object> tableRow1 = new HashMap<>();
|
||||
tableRow1.put("check", true);
|
||||
tableRow1.put("number", 1);
|
||||
tableRow1.put("operator", "GREATER");
|
||||
tableRow1.put("strColumn", "Talend");
|
||||
tableValue.add(tableRow1);
|
||||
final Map<String, Object> tableRow2 = new HashMap<>();
|
||||
tableRow2.put("check", false);
|
||||
tableRow2.put("number", 2);
|
||||
tableRow2.put("operator", "LESS");
|
||||
tableRow2.put("strColumn", "The best");
|
||||
tableValue.add(tableRow2);
|
||||
actionResult.put("table", tableValue);
|
||||
|
||||
command.onResult(actionResult);
|
||||
|
||||
Assertions.assertEquals(expectedValue, table.getValue());
|
||||
}
|
||||
|
||||
public void testOnResultIntegerOption() {
|
||||
final String expectedValue = "42";
|
||||
|
||||
final ButtonParameter button = new ButtonParameter(null);
|
||||
final TextElementParameter text = new TextElementParameter(null);
|
||||
text.setName("conf.updatableConfig.number");
|
||||
text.setFieldType(EParameterFieldType.TEXT);
|
||||
|
||||
final UpdateCommand command = new UpdateCommand(null, "conf.updatableConfig",
|
||||
Collections.singletonMap(text.getName(), text), button);
|
||||
|
||||
final Map<String, Object> actionResult = new HashMap<>();
|
||||
actionResult.put("number", 42);
|
||||
|
||||
command.onResult(actionResult);
|
||||
|
||||
Assertions.assertEquals(expectedValue, text.getValue());
|
||||
}
|
||||
|
||||
public void testOnResultStringOption() {
|
||||
final String expectedValue = "value";
|
||||
|
||||
final ButtonParameter button = new ButtonParameter(null);
|
||||
final TextElementParameter text = new TextElementParameter(null);
|
||||
text.setName("conf.updatableConfig.str");
|
||||
text.setFieldType(EParameterFieldType.TEXT);
|
||||
|
||||
final UpdateCommand command = new UpdateCommand(null, "conf.updatableConfig",
|
||||
Collections.singletonMap(text.getName(), text), button);
|
||||
|
||||
final Map<String, Object> actionResult = new HashMap<>();
|
||||
actionResult.put("str", "value");
|
||||
|
||||
command.onResult(actionResult);
|
||||
|
||||
Assertions.assertEquals(expectedValue, text.getValue());
|
||||
}
|
||||
|
||||
|
||||
public void testOnResultBooleanOption() {
|
||||
final boolean expectedValue = false;
|
||||
|
||||
final ButtonParameter button = new ButtonParameter(null);
|
||||
final CheckElementParameter check = new CheckElementParameter(null);
|
||||
check.setName("conf.updatableConfig.check");
|
||||
check.setFieldType(EParameterFieldType.TEXT);
|
||||
|
||||
final UpdateCommand command = new UpdateCommand(null, "conf.updatableConfig",
|
||||
Collections.singletonMap(check.getName(), check), button);
|
||||
|
||||
final Map<String, Object> actionResult = new HashMap<>();
|
||||
actionResult.put("check", false);
|
||||
|
||||
command.onResult(actionResult);
|
||||
|
||||
Assertions.assertEquals(expectedValue, check.getValue());
|
||||
}
|
||||
|
||||
|
||||
public void testOnResultSchemaOption() {
|
||||
final List<String> expectedValue = Arrays.asList("col1", "col2", "col3");
|
||||
|
||||
final ButtonParameter button = new ButtonParameter(null);
|
||||
final TaCoKitElementParameter schema = new TaCoKitElementParameter(null);
|
||||
schema.setName("conf.updatableConfig.schema");
|
||||
schema.setFieldType(EParameterFieldType.SCHEMA_TYPE);
|
||||
|
||||
final UpdateCommand command = new UpdateCommand(null, "conf.updatableConfig",
|
||||
Collections.singletonMap(schema.getName(), schema), button);
|
||||
|
||||
final Map<String, Object> actionResult = new HashMap<>();
|
||||
final List<String> schemaValue = Arrays.asList("col1", "col2", "col3");
|
||||
actionResult.put("schema", schemaValue);
|
||||
|
||||
command.onResult(actionResult);
|
||||
|
||||
Assertions.assertEquals(expectedValue, schema.getValue());
|
||||
}
|
||||
|
||||
private static class ButtonParameterMock extends ButtonParameter {
|
||||
|
||||
private boolean fireCalled = false;
|
||||
|
||||
public ButtonParameterMock(final IElement element) {
|
||||
super(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void firePropertyChange(final String name, final Object oldValue, final Object newValue) {
|
||||
this.fireCalled = true;
|
||||
}
|
||||
|
||||
boolean firePropertyChangeCalled() {
|
||||
return fireCalled;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.sdk.component.studio.model.action.update;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.json.bind.Jsonb;
|
||||
import javax.json.bind.JsonbBuilder;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.talend.core.model.process.EComponentCategory;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.sdk.component.server.front.model.ActionReference;
|
||||
import org.talend.sdk.component.studio.model.parameter.ButtonParameter;
|
||||
import org.talend.sdk.component.studio.model.parameter.PropertyNode;
|
||||
import org.talend.sdk.component.studio.test.TestComponent;
|
||||
|
||||
public class UpdateResolverTest {
|
||||
|
||||
private static TestComponent component;
|
||||
|
||||
public static void init() throws Exception {
|
||||
component = TestComponent.load("update.json");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks {@link UpdateResolver#resolveParameters(Map)} resolves action parameters correctly
|
||||
* Checks {@link UpdateResolver#resolveParameters(Map)} resolves parameters for update (parameters which are
|
||||
* updated according value from action result) correctly. This check is done via calling {@link UpdateCommand#onResult(Map)}
|
||||
*/
|
||||
public void testResolveParametersWithNestedConfig() throws Exception {
|
||||
final Map<String, String> expectedPayload = new HashMap<>();
|
||||
expectedPayload.put("c", "LESS");
|
||||
expectedPayload.put("s", "Hello world!");
|
||||
|
||||
final PropertyNode actionOwner = component.getNode("conf.updatableConfig");
|
||||
final Collection<ActionReference> actions = component.getActions();
|
||||
final ActionReference actionRef = component.getAction("updatableConfig");
|
||||
final ActionMock action = new ActionMock(actionRef.getName(), actionRef.getFamily());
|
||||
final Map<String, IElementParameter> settings = component.getSettings();
|
||||
final UpdateResolver resolver = new UpdateResolver(null, EComponentCategory.ADVANCED, 0,
|
||||
action, actionOwner,actions, null, settings, () -> true);
|
||||
|
||||
resolver.resolveParameters(settings);
|
||||
|
||||
Assertions.assertEquals(expectedPayload, action.checkPayload());
|
||||
|
||||
final ButtonParameter button = (ButtonParameter) settings.get("conf.updatableConfig.update");
|
||||
final UpdateCommand command = (UpdateCommand) button.getCommand();
|
||||
final Map<String, Object> actionResult = loadActionResult("updateActionResult.json");
|
||||
command.onResult(actionResult);
|
||||
|
||||
Assertions.assertEquals("1st level str value", settings.get("conf.updatableConfig.str").getValue());
|
||||
Assertions.assertEquals("2nd level str1 value", settings.get("conf.updatableConfig.nestedConfig.str1").getValue());
|
||||
Assertions.assertEquals("2nd level str2 value", settings.get("conf.updatableConfig.nestedConfig.str2").getValue());
|
||||
}
|
||||
|
||||
private Map<String, Object> loadActionResult(final String resource) throws Exception {
|
||||
try (final Jsonb jsonb = JsonbBuilder.create();
|
||||
final InputStream stream =
|
||||
Thread.currentThread().getContextClassLoader().getResourceAsStream(resource)) {
|
||||
return jsonb.fromJson(stream, Map.class);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ActionMock extends UpdateAction {
|
||||
|
||||
public ActionMock(final String actionName, final String family) {
|
||||
super(actionName, family);
|
||||
}
|
||||
|
||||
public Map<String, String> checkPayload() {
|
||||
return super.payload();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio.model.connector;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.talend.core.model.process.EConnectionType;
|
||||
|
||||
/**
|
||||
* Unit-tests for {@link AbstractConnectorCreator}
|
||||
*/
|
||||
class AbstractConnectorCreatorTest {
|
||||
|
||||
private static final String DEFAULT = "__default__";
|
||||
|
||||
@Test
|
||||
void testGetTypeDefault() {
|
||||
EConnectionType expectedType = EConnectionType.FLOW_MAIN;
|
||||
EConnectionType actualType = AbstractConnectorCreator.getType(DEFAULT);
|
||||
assertEquals(expectedType, actualType);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetTypeMain() {
|
||||
EConnectionType expectedType = EConnectionType.FLOW_MAIN;
|
||||
EConnectionType actualType = AbstractConnectorCreator.getType("Main");
|
||||
assertEquals(expectedType, actualType);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetTypeReject() {
|
||||
EConnectionType expectedType = EConnectionType.REJECT;
|
||||
EConnectionType actualType = AbstractConnectorCreator.getType("reject");
|
||||
assertEquals(expectedType, actualType);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetTypeRejectUpperCase() {
|
||||
EConnectionType expectedType = EConnectionType.REJECT;
|
||||
EConnectionType actualType = AbstractConnectorCreator.getType("REJECT");
|
||||
assertEquals(expectedType, actualType);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetNameDefault() {
|
||||
String expectedName = EConnectionType.FLOW_MAIN.getName();
|
||||
String actualName = AbstractConnectorCreator.getName(DEFAULT);
|
||||
assertEquals(expectedName, actualName);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetNameAny() {
|
||||
String expectedName = "Any";
|
||||
String actualName = AbstractConnectorCreator.getName("Any");
|
||||
assertEquals(expectedName, actualName);
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package org.talend.sdk.component.studio.model.parameter;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.talend.core.model.metadata.IMetadataColumn;
|
||||
import org.talend.core.model.metadata.IMetadataTable;
|
||||
import org.talend.core.model.metadata.MetadataColumn;
|
||||
import org.talend.core.model.metadata.MetadataTable;
|
||||
import org.talend.designer.core.ui.editor.nodes.Node;
|
||||
import org.talend.sdk.component.studio.lang.Pair;
|
||||
import org.talend.sdk.component.studio.model.action.IActionParameter;
|
||||
|
||||
class OutputSchemaParameterTest {
|
||||
|
||||
private static final String CONNECTOR_NAME = "FLOW";
|
||||
|
||||
@Test
|
||||
void testCreateActionParameter() {
|
||||
final Node nodeMock = mockNode(metadata());
|
||||
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true, Collections.emptyList());
|
||||
final IActionParameter actionParameter = parameter.createActionParameter("param");
|
||||
final Collection<Pair<String, String>> parameters = actionParameter.parameters();
|
||||
|
||||
assertEquals(2, parameters.size());
|
||||
final Iterator<Pair<String, String>> iterator = parameters.iterator();
|
||||
assertEquals(new Pair<String, String>("param[0]", "c1"), iterator.next());
|
||||
assertEquals(new Pair<String, String>("param[1]", "c2"), iterator.next());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetValue() {
|
||||
final Node nodeMock = mockNode(metadata());
|
||||
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true, Collections.emptyList());
|
||||
assertEquals(Arrays.asList("c1", "c2"), parameter.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetValueNoMetadata() {
|
||||
final Node nodeMock = mockNode(null);
|
||||
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true, Collections.emptyList());
|
||||
assertEquals(Collections.emptyList(), parameter.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetStringValue() {
|
||||
final Node nodeMock = mockNode(metadata());
|
||||
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true, Collections.emptyList());
|
||||
assertEquals("[c1, c2]", parameter.getStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGetStringValueNoMetadata() {
|
||||
final Node nodeMock = mockNode(null);
|
||||
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true, Collections.emptyList());
|
||||
assertEquals("[]", parameter.getStringValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetValue() {
|
||||
final IMetadataTable metadata = new MetadataTable();
|
||||
final Node nodeMock = mockNode(metadata);
|
||||
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true, Collections.emptyList());
|
||||
|
||||
final List<String> schema = Arrays.asList("c1", "c2", "c3");
|
||||
parameter.setValue(schema);
|
||||
|
||||
assertEquals(3, metadata.getListColumns().size());
|
||||
final List<String> actualLabels = metadata.getListColumns().stream()
|
||||
.map(IMetadataColumn::getLabel)
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(Arrays.asList("c1", "c2", "c3"), actualLabels);
|
||||
|
||||
final List<String> actualDbColumnNames = metadata.getListColumns().stream()
|
||||
.map(IMetadataColumn::getOriginalDbColumnName)
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(Arrays.asList("c1", "c2", "c3"), actualDbColumnNames);
|
||||
|
||||
final List<String> actualTypes = metadata.getListColumns().stream()
|
||||
.map(IMetadataColumn::getTalendType)
|
||||
.collect(Collectors.toList());
|
||||
assertEquals(Arrays.asList("id_String", "id_String", "id_String"), actualTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check there is no exception in case of MetadataTable is missed
|
||||
*/
|
||||
@Test
|
||||
void testSetValueNoMetadata() {
|
||||
final Node nodeMock = mockNode(null);
|
||||
final OutputSchemaParameter parameter = new OutputSchemaParameter(nodeMock, "schema", CONNECTOR_NAME, null, true, Collections.emptyList());
|
||||
|
||||
final List<String> schema = Arrays.asList("c1", "c2", "c3");
|
||||
parameter.setValue(schema);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIsPersisted() {
|
||||
final OutputSchemaParameter parameter = new OutputSchemaParameter(null, "schema", CONNECTOR_NAME, null, true, Collections.emptyList());
|
||||
Assertions.assertTrue(parameter.isPersisted());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGuessButtonName() {
|
||||
assertEquals("Guess Schema_config.datastore.dataset", OutputSchemaParameter.guessButtonName("config.datastore.dataset"));
|
||||
}
|
||||
|
||||
private Node mockNode(final IMetadataTable metadata) {
|
||||
final Node nodeMock = mock(Node.class);
|
||||
when(nodeMock.getMetadataFromConnector(CONNECTOR_NAME)).thenReturn(metadata);
|
||||
return nodeMock;
|
||||
}
|
||||
|
||||
private IMetadataTable metadata() {
|
||||
final IMetadataTable metadata = new MetadataTable();
|
||||
final List<IMetadataColumn> columns = new ArrayList<>();
|
||||
|
||||
final IMetadataColumn c1 = new MetadataColumn();
|
||||
c1.setLabel("c1");
|
||||
columns.add(c1);
|
||||
|
||||
final IMetadataColumn c2 = new MetadataColumn();
|
||||
c2.setLabel("c2");
|
||||
columns.add(c2);
|
||||
metadata.setListColumns(columns);
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package org.talend.sdk.component.studio.model.parameter;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.talend.core.model.process.EComponentCategory;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.sdk.component.server.front.model.SimplePropertyDefinition;
|
||||
|
||||
class SettingVisitorTest {
|
||||
|
||||
@Test
|
||||
void getSettings() {
|
||||
final SettingVisitor visitor = new SettingVisitor(null, null, Collections.emptyList())
|
||||
.withCategory(EComponentCategory.MAIN);
|
||||
|
||||
final PropertyNode nodeValue = this.nodeValue();
|
||||
visitor.visit(nodeValue);
|
||||
|
||||
|
||||
final PropertyNode node = this.newNode();
|
||||
visitor.visit(node);
|
||||
|
||||
final PropertyNode node2 = this.newNode();
|
||||
visitor.visit(node2);
|
||||
|
||||
visitor.getSettings();
|
||||
}
|
||||
|
||||
private PropertyNode nodeValue() {
|
||||
final SimplePropertyDefinition def = new SimplePropertyDefinition();
|
||||
final PropertyDefinitionDecorator prop = new PropertyDefinitionDecorator(def);
|
||||
|
||||
def.setPath("value");
|
||||
def.setMetadata(new HashMap<>());
|
||||
final PropertyNode node = new PropertyNode(prop, EParameterFieldType.TEXT, true);
|
||||
node.getLayouts().put("Main", new Layout("Main"));
|
||||
return node;
|
||||
}
|
||||
|
||||
private PropertyNode newNode() {
|
||||
final SimplePropertyDefinition def = new SimplePropertyDefinition();
|
||||
final PropertyDefinitionDecorator prop = new PropertyDefinitionDecorator(def);
|
||||
|
||||
def.setPath("hello");
|
||||
def.setMetadata(new HashMap<>());
|
||||
def.getMetadata().put(Metadatas.CONDITION_IF_TARGET, "value");
|
||||
|
||||
final PropertyNode node = new PropertyNode(prop, EParameterFieldType.MAPPING_TYPE, true);
|
||||
|
||||
node.getLayouts().put("Main", new Layout("Main"));
|
||||
return node;
|
||||
}
|
||||
}
|
||||
@@ -1,171 +0,0 @@
|
||||
// ============================================================================
|
||||
//
|
||||
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
//
|
||||
// This source code is available under agreement available at
|
||||
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
|
||||
//
|
||||
// You should have received a copy of the agreement
|
||||
// along with this program; if not, write to Talend SA
|
||||
// 9 rue Pages 92150 Suresnes, France
|
||||
//
|
||||
// ============================================================================
|
||||
package org.talend.sdk.component.studio.model.parameter;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.talend.core.model.process.EParameterFieldType;
|
||||
import org.talend.sdk.component.studio.lang.Pair;
|
||||
import org.talend.sdk.component.studio.model.action.IActionParameter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class TableElementParameterTest {
|
||||
|
||||
@Test
|
||||
public void testCreateActionParameter() {
|
||||
final List<Pair<String, String>> expected = new ArrayList<>();
|
||||
final Pair<String, String> p1 = new Pair("t[0].id", "id value 0");
|
||||
expected.add(p1);
|
||||
final Pair<String, String> p2 = new Pair("t[0].name", "name 0");
|
||||
expected.add(p2);
|
||||
final Pair<String, String> p3 = new Pair("t[0].number", "number 0");
|
||||
expected.add(p3);
|
||||
final Pair<String, String> p4 = new Pair("t[1].id", "id value 1");
|
||||
expected.add(p4);
|
||||
final Pair<String, String> p5 = new Pair("t[1].name", "name 1");
|
||||
expected.add(p5);
|
||||
final Pair<String, String> p6 = new Pair("t[1].number", "number 1");
|
||||
expected.add(p6);
|
||||
|
||||
final List<Map<String, String>> value = new ArrayList<>();
|
||||
final Map<String, String> row1 = new LinkedHashMap<>();
|
||||
row1.put("conf.table[].id", "id value 0");
|
||||
row1.put("conf.table[].name", "name 0");
|
||||
row1.put("conf.table[].number", "number 0");
|
||||
value.add(row1);
|
||||
final Map<String, String> row2 = new LinkedHashMap<>();
|
||||
row2.put("conf.table[].id", "id value 1");
|
||||
row2.put("conf.table[].name", "name 1");
|
||||
row2.put("conf.table[].number", "number 1");
|
||||
value.add(row2);
|
||||
|
||||
final TableElementParameter parameter = new TableElementParameter(null, Collections.emptyList());
|
||||
parameter.setName("conf.table");
|
||||
parameter.setValue(value);
|
||||
|
||||
final IActionParameter actionParameter = parameter.createActionParameter("t");
|
||||
final Collection<Pair<String, String>> parameters = actionParameter.parameters();
|
||||
Assertions.assertEquals(expected, parameters);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateActionParameterNull() {
|
||||
final List<Pair<String, String>> expected = new ArrayList<>();
|
||||
|
||||
final TableElementParameter parameter = new TableElementParameter(null, Collections.emptyList());
|
||||
parameter.setName("conf.table");
|
||||
|
||||
final IActionParameter actionParameter = parameter.createActionParameter("t");
|
||||
final Collection<Pair<String, String>> parameters = actionParameter.parameters();
|
||||
Assertions.assertEquals(expected, parameters);
|
||||
}
|
||||
@Test
|
||||
public void testCreateActionParameterEmpty() {
|
||||
final List<Pair<String, String>> expected = new ArrayList<>();
|
||||
|
||||
final TableElementParameter parameter = new TableElementParameter(null, Collections.emptyList());
|
||||
parameter.setName("conf.table");
|
||||
parameter.setValue(new ArrayList<>());
|
||||
|
||||
final IActionParameter actionParameter = parameter.createActionParameter("t");
|
||||
final Collection<Pair<String, String>> parameters = actionParameter.parameters();
|
||||
Assertions.assertEquals(expected, parameters);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetValueFixClosedList() {
|
||||
final List<Map<String, Object>> expectedValue = new ArrayList<>();
|
||||
final Map<String, Object> expectedRow1 = new LinkedHashMap<>();
|
||||
expectedRow1.put("conf.table[].check", "false");
|
||||
expectedRow1.put("conf.table[].enum", "GREATER");
|
||||
expectedValue.add(expectedRow1);
|
||||
|
||||
final CheckElementParameter col1 = new CheckElementParameter(null);
|
||||
col1.setName("conf.table[].check");
|
||||
col1.setFieldType(EParameterFieldType.CHECK);
|
||||
|
||||
final TaCoKitElementParameter col2 = new TaCoKitElementParameter(null);
|
||||
final Object[] col2PossibleValues = new String[]{"GREATER", "LESS", "EQUALS"};
|
||||
col2.setName("conf.table[].enum");
|
||||
col2.setListItemsValue(col2PossibleValues);
|
||||
col2.setFieldType(EParameterFieldType.CLOSED_LIST);
|
||||
|
||||
final TableElementParameter table = new TableElementParameter(null, Collections.emptyList());
|
||||
final Object[] tableColumns = new Object[]{col1, col2};
|
||||
table.setListItemsValue(tableColumns);
|
||||
table.setName("conf.table");
|
||||
|
||||
final List<Map<String, Object>> newValue = new ArrayList<>();
|
||||
final Map<String, Object> newRow1 = new LinkedHashMap<>();
|
||||
newRow1.put("conf.table[].check", "false");
|
||||
newRow1.put("conf.table[].enum", 0);
|
||||
newValue.add(newRow1);
|
||||
|
||||
table.setValue(newValue);
|
||||
|
||||
Assertions.assertEquals(expectedValue, table.getValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetValueFromAction() {
|
||||
final List<Map<String, Object>> expectedValue = new ArrayList<Map<String, Object>>();
|
||||
final Map<String, Object> row1 = new HashMap<>();
|
||||
row1.put("conf.updatableConfig.table[].check", true);
|
||||
row1.put("conf.updatableConfig.table[].number", "1");
|
||||
row1.put("conf.updatableConfig.table[].operator", "GREATER");
|
||||
row1.put("conf.updatableConfig.table[].strColumn", "Talend");
|
||||
expectedValue.add(row1);
|
||||
final Map<String, Object> row2 = new HashMap<>();
|
||||
row2.put("conf.updatableConfig.table[].check", false);
|
||||
row2.put("conf.updatableConfig.table[].number", "2");
|
||||
row2.put("conf.updatableConfig.table[].operator", "LESS");
|
||||
row2.put("conf.updatableConfig.table[].strColumn", "The best");
|
||||
expectedValue.add(row2);
|
||||
|
||||
final TableElementParameter table = new TableElementParameter(null, Collections.emptyList());
|
||||
table.setName("conf.updatableConfig.table");
|
||||
table.setFieldType(EParameterFieldType.TABLE);
|
||||
final TaCoKitElementParameter column1 = new TaCoKitElementParameter(null);
|
||||
column1.setFieldType(EParameterFieldType.CHECK);
|
||||
column1.setName("conf.updatableConfig.table[].check");
|
||||
final TaCoKitElementParameter column2 = new TaCoKitElementParameter(null);
|
||||
column2.setFieldType(EParameterFieldType.TEXT);
|
||||
column2.setName("conf.updatableConfig.table[].number");
|
||||
final TaCoKitElementParameter column3 = new TaCoKitElementParameter(null);
|
||||
column3.setFieldType(EParameterFieldType.CLOSED_LIST);
|
||||
column3.setName("conf.updatableConfig.table[].operator");
|
||||
final TaCoKitElementParameter column4 = new TaCoKitElementParameter(null);
|
||||
column4.setFieldType(EParameterFieldType.TEXT);
|
||||
column4.setName("conf.updatableConfig.table[].strColumn");
|
||||
table.setListItemsValue(new Object[] {column1, column2, column3, column4});
|
||||
|
||||
final List<Object> tableValue = new ArrayList<>();
|
||||
final Map<String, Object> tableRow1 = new HashMap<>();
|
||||
tableRow1.put("check", true);
|
||||
tableRow1.put("number", 1);
|
||||
tableRow1.put("operator", "GREATER");
|
||||
tableRow1.put("strColumn", "Talend");
|
||||
tableValue.add(tableRow1);
|
||||
final Map<String, Object> tableRow2 = new HashMap<>();
|
||||
tableRow2.put("check", false);
|
||||
tableRow2.put("number", 2);
|
||||
tableRow2.put("operator", "LESS");
|
||||
tableRow2.put("strColumn", "The best");
|
||||
tableValue.add(tableRow2);
|
||||
|
||||
table.setValueFromAction(tableValue);
|
||||
Assertions.assertEquals(expectedValue, table.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio.model.parameter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Unit-tests for {@link ValueConverter}
|
||||
*/
|
||||
class ValueConverterTest {
|
||||
|
||||
@Test
|
||||
void testToTable() {
|
||||
Map<String, Object> expected0 = new HashMap<>();
|
||||
expected0.put("key1", "value11");
|
||||
expected0.put("key2", "value12");
|
||||
Map<String, Object> expected1 = new HashMap<>();
|
||||
expected1.put("key1", "value21");
|
||||
expected1.put("key2", "value22");
|
||||
|
||||
String table = "[{key1=value11, key2=value12}, {key1=value21, key2=value22}]";
|
||||
List<Map<String, Object>> converted = ValueConverter.toTable(table);
|
||||
Assertions.assertEquals(2, converted.size());
|
||||
Assertions.assertEquals(expected0, converted.get(0));
|
||||
Assertions.assertEquals(expected1, converted.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToTableNull() {
|
||||
ArrayList<Map<String, Object>> empty = new ArrayList<>();
|
||||
List<Map<String, Object>> actual = ValueConverter.toTable(null);
|
||||
Assertions.assertEquals(empty, actual);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToTableEmpty() {
|
||||
ArrayList<Map<String, Object>> empty = new ArrayList<>();
|
||||
List<Map<String, Object>> actual = ValueConverter.toTable("");
|
||||
Assertions.assertEquals(empty, actual);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio.model.parameter.listener;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static java.util.Collections.singletonMap;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.talend.sdk.component.studio.model.parameter.PropertyDefinitionDecorator.Condition;
|
||||
import org.talend.sdk.component.studio.model.parameter.TaCoKitElementParameter;
|
||||
import org.talend.sdk.component.studio.model.parameter.TextElementParameter;
|
||||
import org.talend.sdk.component.studio.model.parameter.condition.ConditionGroup;
|
||||
|
||||
// todo: check why these tests are correct, seems it happens on the property change
|
||||
// and not the relational conditions changes
|
||||
class ActiveIfListenerTest {
|
||||
@Test
|
||||
void containsNegative() {
|
||||
final TacokitTestParameter param = new TacokitTestParameter("-");
|
||||
new ActiveIfListener(singletonList(
|
||||
new ConditionGroup(
|
||||
singletonList(new Condition(new String[] { "A" }, "a", false, "contains")), true)),
|
||||
param, singletonMap("a", new TacokitTestParameter("foo")))
|
||||
.propertyChange(new PropertyChangeEvent(param, "value", "bar", "foo"));
|
||||
assertFalse(param.setShowValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
void contains() {
|
||||
final TacokitTestParameter param = new TacokitTestParameter("-");
|
||||
new ActiveIfListener(singletonList(
|
||||
new ConditionGroup(
|
||||
singletonList(new Condition(new String[] { "A" }, "a", false, "contains")), true)),
|
||||
param, singletonMap("a", new TacokitTestParameter("bAr")))
|
||||
.propertyChange(new PropertyChangeEvent(param, "value", "foo", "bAr"));
|
||||
assertTrue(param.setShowValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
void containsLowercase() {
|
||||
final TacokitTestParameter param = new TacokitTestParameter("-");
|
||||
new ActiveIfListener(singletonList(
|
||||
new ConditionGroup(
|
||||
singletonList(new Condition(
|
||||
new String[] { "a" }, "a", false, "contains(lowercase=true)")), true)),
|
||||
param, singletonMap("a", new TacokitTestParameter("bAR")))
|
||||
.propertyChange(new PropertyChangeEvent(param, "value", "foo", "bAr"));
|
||||
assertTrue(param.setShowValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
void notActivatedCondition() {
|
||||
final TacokitTestParameter param = new TacokitTestParameter("-");
|
||||
new ActiveIfListener(singletonList(
|
||||
new ConditionGroup(
|
||||
singletonList(new Condition(new String[] { "A" }, "a", false, "DEFAULT")), true)),
|
||||
param, singletonMap("a", new TacokitTestParameter("C")))
|
||||
.propertyChange(new PropertyChangeEvent(param, "value", "foo", "bar"));
|
||||
assertFalse(param.setShowValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
void singleCondition() {
|
||||
final TacokitTestParameter param = new TacokitTestParameter("-");
|
||||
new ActiveIfListener(singletonList(
|
||||
new ConditionGroup(
|
||||
singletonList(new Condition(new String[] { "A" }, "a", false, "DEFAULT")), true)),
|
||||
param, singletonMap("a", new TacokitTestParameter("A")))
|
||||
.propertyChange(new PropertyChangeEvent(param, "value", "foo", "bar"));
|
||||
assertTrue(param.setShowValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
void andCondition() {
|
||||
final TacokitTestParameter param = new TacokitTestParameter("-");
|
||||
new ActiveIfListener(singletonList(
|
||||
new ConditionGroup(
|
||||
asList(
|
||||
new Condition(new String[] { "A" }, "a", false, "DEFAULT"),
|
||||
new Condition(new String[] { "B" }, "b", false, "DEFAULT")),
|
||||
true)),
|
||||
param, new HashMap<String, TaCoKitElementParameter>() {{
|
||||
put("a", new TacokitTestParameter("A"));
|
||||
put("b", new TacokitTestParameter("B"));
|
||||
}}).propertyChange(new PropertyChangeEvent(param, "value", "foo", "bar"));
|
||||
assertTrue(param.setShowValue);
|
||||
}
|
||||
|
||||
@Test
|
||||
void orCondition() {
|
||||
final TacokitTestParameter param = new TacokitTestParameter("-");
|
||||
new ActiveIfListener(singletonList(
|
||||
new ConditionGroup(
|
||||
asList(
|
||||
new Condition(new String[] { "A" }, "a", false, "DEFAULT"),
|
||||
new Condition(new String[] { "B" }, "b", false, "DEFAULT")),
|
||||
false)),
|
||||
param, new HashMap<String, TaCoKitElementParameter>() {{
|
||||
put("a", new TacokitTestParameter("A"));
|
||||
put("b", new TacokitTestParameter("C"));
|
||||
}}).propertyChange(new PropertyChangeEvent(param, "value", "foo", "bar"));
|
||||
assertTrue(param.setShowValue);
|
||||
}
|
||||
|
||||
private static class TacokitTestParameter extends TextElementParameter {
|
||||
private final String value;
|
||||
private boolean setShowValue;
|
||||
|
||||
private TacokitTestParameter(final String value) {
|
||||
super(null);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShow(boolean show) {
|
||||
this.setShowValue = show;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void redraw() {
|
||||
// no-op
|
||||
}
|
||||
|
||||
@Override
|
||||
public void firePropertyChange(final String name, final Object oldValue, final Object newValue) {
|
||||
// no-op
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio.model.parameter.listener;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.talend.sdk.component.studio.model.parameter.ValidationLabel;
|
||||
|
||||
|
||||
class PatternValidatorTest {
|
||||
|
||||
@Test
|
||||
void simpleRegex() {
|
||||
Stream.of(
|
||||
new RegexCases("\\S+@\\S+\\.\\S+", asList("foo@bar.com", "test.thing@dummy.provider.com"),
|
||||
asList("wrong", "notgoodgmail.com")),
|
||||
new RegexCases("^[a-zA-Z ]+$", asList("John Doe", "Some other Name"),
|
||||
asList("@bsolutely wrong", "Not a Name v3")))
|
||||
.flatMap(base -> Stream.of(base, new RegexCases("/^" + base.regex + "$/", base.validTexts, base.invalidTexts)))
|
||||
.forEach(Runnable::run);
|
||||
}
|
||||
|
||||
@Test
|
||||
void withFlags() {
|
||||
new RegexCases("/[a-z]+/i", asList("foo", "FOO", "FoO"), asList("123", "@")).run();
|
||||
}
|
||||
|
||||
private static class RegexCases implements Runnable {
|
||||
|
||||
private final PatternValidator regex;
|
||||
|
||||
private final Collection<String> validTexts;
|
||||
|
||||
private final Collection<String> invalidTexts;
|
||||
|
||||
private RegexCases(final String regex, final Collection<String> validTexts, final Collection<String> invalidTexts) {
|
||||
this.regex = new PatternValidator(new ValidationLabel(null), regex);
|
||||
this.validTexts = validTexts;
|
||||
this.invalidTexts = invalidTexts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
validTexts.forEach(v -> validate(v, true));
|
||||
invalidTexts.forEach(v -> validate(v, false));
|
||||
}
|
||||
|
||||
private void validate(final String value, final boolean state) {
|
||||
assertEquals(state, regex.validate(value), "Error in validating " + regex + " > " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio.model.parameter.resolver;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.sdk.component.server.front.model.ActionReference;
|
||||
import org.talend.sdk.component.studio.model.action.SuggestionsAction;
|
||||
import org.talend.sdk.component.studio.model.parameter.PropertyNode;
|
||||
import org.talend.sdk.component.studio.model.parameter.TableElementParameter;
|
||||
import org.talend.sdk.component.studio.test.TestComponent;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class SuggestionsResolverTest {
|
||||
|
||||
private static TestComponent component;
|
||||
|
||||
@BeforeAll
|
||||
public static void init() throws Exception {
|
||||
component = TestComponent.load("suggestions.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveParametersOrder() {
|
||||
final Map<String, String> expectedPayload = new HashMap<>();
|
||||
expectedPayload.put("p", "primitive value");
|
||||
expectedPayload.put("a", "another value");
|
||||
|
||||
final PropertyNode actionOwner = component.getNode("conf.basedOnTwoPrimitives");
|
||||
final Collection<ActionReference> actions = component.getActions();
|
||||
final ActionReference actionRef = component.getAction("basedOnTwoPrimitives");
|
||||
final ActionMock action = new ActionMock(actionRef.getName(), actionRef.getFamily());
|
||||
final SuggestionsResolver resolver = new SuggestionsResolver(action, actionOwner, actions);
|
||||
|
||||
final Map<String, IElementParameter> settings = component.getSettings();
|
||||
resolver.resolveParameters(settings);
|
||||
|
||||
assertEquals(expectedPayload, action.checkPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveParametersOrderComplex() {
|
||||
final Map<String, String> expectedPayload = new HashMap<>();
|
||||
expectedPayload.put("c.complexString", "complex string");
|
||||
expectedPayload.put("c.complexInt", "-1");
|
||||
expectedPayload.put("ds.url", "http://initial.url");
|
||||
expectedPayload.put("ds.port", "8080");
|
||||
|
||||
final PropertyNode actionOwner = component.getNode("conf.basedOnComplex");
|
||||
final Collection<ActionReference> actions = component.getActions();
|
||||
final ActionReference actionRef = component.getAction("basedOnComplex");
|
||||
final ActionMock action = new ActionMock(actionRef.getName(), actionRef.getFamily());
|
||||
final SuggestionsResolver resolver = new SuggestionsResolver(action, actionOwner, actions);
|
||||
|
||||
final Map<String, IElementParameter> settings = component.getSettings();
|
||||
resolver.resolveParameters(settings);
|
||||
|
||||
assertEquals(expectedPayload, action.checkPayload());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveParametersTable() {
|
||||
final Map<String, String> expectedPayload = new HashMap<>();
|
||||
expectedPayload.put("table[0].check", "true");
|
||||
expectedPayload.put("table[0].number", "1");
|
||||
expectedPayload.put("table[0].operator", "GREATER");
|
||||
expectedPayload.put("table[0].strColumn", "Talend");
|
||||
expectedPayload.put("table[1].check", "false");
|
||||
expectedPayload.put("table[1].number", "2");
|
||||
expectedPayload.put("table[1].operator", "LESS");
|
||||
expectedPayload.put("table[1].strColumn", "The best");
|
||||
|
||||
final PropertyNode actionOwner = component.getNode("conf.basedOnTable");
|
||||
final Collection<ActionReference> actions = component.getActions();
|
||||
final ActionReference actionRef = component.getAction("basedOnTable");
|
||||
final ActionMock action = new ActionMock(actionRef.getName(), actionRef.getFamily());
|
||||
final SuggestionsResolver resolver = new SuggestionsResolver(action, actionOwner, actions);
|
||||
|
||||
final Map<String, IElementParameter> settings = component.getSettings();
|
||||
final TableElementParameter tableParam = createTableParameter();
|
||||
settings.put("conf.table", tableParam);
|
||||
|
||||
resolver.resolveParameters(settings);
|
||||
|
||||
assertEquals(expectedPayload, action.checkPayload());
|
||||
}
|
||||
|
||||
private TableElementParameter createTableParameter() {
|
||||
|
||||
final List<Map<String, String>> tableValue = new ArrayList<>();
|
||||
final Map<String, String> row1 = new HashMap<>();
|
||||
row1.put("conf.table[].check", "true");
|
||||
row1.put("conf.table[].number", "1");
|
||||
row1.put("conf.table[].operator", "GREATER");
|
||||
row1.put("conf.table[].strColumn", "Talend");
|
||||
tableValue.add(row1);
|
||||
final Map<String, String> row2 = new HashMap<>();
|
||||
row2.put("conf.table[].check", "false");
|
||||
row2.put("conf.table[].number", "2");
|
||||
row2.put("conf.table[].operator", "LESS");
|
||||
row2.put("conf.table[].strColumn", "The best");
|
||||
tableValue.add(row2);
|
||||
|
||||
final TableElementParameter tableParam = new TableElementParameter(null, Collections.emptyList());
|
||||
tableParam.setName("conf.table");
|
||||
tableParam.setValue(tableValue);
|
||||
return tableParam;
|
||||
}
|
||||
|
||||
private static class ActionMock extends SuggestionsAction {
|
||||
|
||||
public ActionMock(final String actionName, final String family) {
|
||||
super(actionName, family);
|
||||
}
|
||||
|
||||
public Map<String, String> checkPayload() {
|
||||
return super.payload();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio.model.parameter.resolver;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.designer.core.model.components.ElementParameter;
|
||||
import org.talend.sdk.component.server.front.model.ActionReference;
|
||||
import org.talend.sdk.component.studio.model.parameter.PropertyNode;
|
||||
import org.talend.sdk.component.studio.model.parameter.listener.ValidationListener;
|
||||
import org.talend.sdk.component.studio.test.TestComponent;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class ValidationResolverTest {
|
||||
|
||||
private static TestComponent component;
|
||||
|
||||
@BeforeAll
|
||||
public static void init() throws Exception {
|
||||
component = TestComponent.load("suggestions.json");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveParametersOrderPrimitives() {
|
||||
Map<String, String> expectedPayload = new HashMap<>();
|
||||
expectedPayload.put("xPort", "8080");
|
||||
expectedPayload.put("yUrl", "http://initial.url");
|
||||
expectedPayload.put("z", "based on 2 primitives");
|
||||
|
||||
final PropertyNode actionOwner = component.getNode("conf.basedOnTwoPrimitives");
|
||||
final Collection<ActionReference> actions = component.getActions();
|
||||
final ValidationListenerMock listener = createValidationListener(component.getAction("checkSeveral"));
|
||||
final ValidationResolver resolver = new ValidationResolver(actionOwner, component.getActions(), listener, new ElementParameter(null));
|
||||
|
||||
final Map<String, IElementParameter> settings = component.getSettings();
|
||||
resolver.resolveParameters(settings);
|
||||
|
||||
assertEquals(expectedPayload, listener.checkPayload());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveParametersOrderComplex() {
|
||||
Map<String, String> expectedPayload = new HashMap<>();
|
||||
expectedPayload.put("s", "based on complex");
|
||||
expectedPayload.put("d.url", "http://initial.url");
|
||||
expectedPayload.put("d.port", "8080");
|
||||
|
||||
final PropertyNode actionOwner = component.getNode("conf.basedOnComplex");
|
||||
final Collection<ActionReference> actions = component.getActions();
|
||||
final ValidationListenerMock listener = createValidationListener(component.getAction("checkComplex"));
|
||||
final ValidationResolver resolver = new ValidationResolver(actionOwner, component.getActions(), listener, new ElementParameter(null));
|
||||
|
||||
final Map<String, IElementParameter> settings = component.getSettings();
|
||||
resolver.resolveParameters(settings);
|
||||
|
||||
assertEquals(expectedPayload, listener.checkPayload());
|
||||
}
|
||||
|
||||
private ValidationListenerMock createValidationListener(final ActionReference action) {
|
||||
return new ValidationListenerMock(action.getFamily(), action.getName());
|
||||
}
|
||||
|
||||
private static class ValidationListenerMock extends ValidationListener {
|
||||
|
||||
public ValidationListenerMock(final String family, final String actionName) {
|
||||
super(null, family, actionName);
|
||||
}
|
||||
|
||||
public Map<String, String> checkPayload() {
|
||||
return super.payload();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package org.talend.sdk.component.studio.service;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class AsciidoctorServiceTest {
|
||||
|
||||
@Test void init() {
|
||||
final AsciidoctorService instance = new AsciidoctorService();
|
||||
String result = instance.convert("= Header");
|
||||
assertEquals("<h1>Header</h1>",result.trim());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/**
|
||||
* Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.talend.sdk.component.studio.test;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.sdk.component.api.configuration.action.meta.ActionRef;
|
||||
import org.talend.sdk.component.server.front.model.ActionReference;
|
||||
import org.talend.sdk.component.server.front.model.SimplePropertyDefinition;
|
||||
import org.talend.sdk.component.studio.model.parameter.PropertyNode;
|
||||
import org.talend.sdk.component.studio.model.parameter.TaCoKitElementParameter;
|
||||
|
||||
import javax.json.bind.Jsonb;
|
||||
import javax.json.bind.JsonbBuilder;
|
||||
import javax.json.bind.annotation.JsonbCreator;
|
||||
import javax.json.bind.annotation.JsonbProperty;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class TestComponent {
|
||||
|
||||
public static final Logger LOG = LoggerFactory.getLogger(TestComponent.class);
|
||||
|
||||
private List<ActionReference> actions;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<PropertyNode> nodes;
|
||||
|
||||
private List<SimplePropertyDefinition> properties;
|
||||
|
||||
private List<TaCoKitElementParameter> settings;
|
||||
|
||||
public static TestComponent load(final String resource) throws Exception {
|
||||
try (final Jsonb jsonb = JsonbBuilder.create();
|
||||
final InputStream stream =
|
||||
Thread.currentThread().getContextClassLoader().getResourceAsStream(resource)) {
|
||||
return jsonb.fromJson(stream, TestComponent.class);
|
||||
}
|
||||
}
|
||||
|
||||
@JsonbCreator
|
||||
public TestComponent(@JsonbProperty("actions") final List<ActionReference> actions,
|
||||
@JsonbProperty("name") final String name,
|
||||
@JsonbProperty("properties") final List<SimplePropertyDefinition> properties,
|
||||
@JsonbProperty("nodes") final List<PropertyNode> nodes,
|
||||
@JsonbProperty("settings") final List<TaCoKitElementParameter> settings) {
|
||||
this.actions = actions;
|
||||
this.name = name;
|
||||
this.properties = properties;
|
||||
this.nodes = nodes;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ActionReference getAction(final String name) {
|
||||
return actions.stream()
|
||||
.filter(a -> name.equals(a.getName()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalArgumentException("no action with name " + name));
|
||||
}
|
||||
|
||||
public List<ActionReference> getActions() {
|
||||
return new ArrayList<>(this.actions);
|
||||
}
|
||||
|
||||
public PropertyNode getNode(final String name) {
|
||||
return nodes.stream()
|
||||
.filter(p -> name.equals(p.getProperty().getPath()))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new IllegalArgumentException("no property with name " + name));
|
||||
}
|
||||
|
||||
public Map<String, IElementParameter> getSettings() {
|
||||
final Map<String, IElementParameter> result = new HashMap<>();
|
||||
settings.forEach(p -> {
|
||||
result.put(p.getName(), p);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package org.talend.sdk.component.studio.ui.wizard.page;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.internal.registry.ExtensionRegistry;
|
||||
import org.eclipse.core.internal.registry.RegistryProviderFactory;
|
||||
import org.eclipse.core.internal.registry.osgi.RegistryProviderOSGI;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.talend.core.model.process.IElementParameter;
|
||||
import org.talend.core.model.repository.ERepositoryObjectType;
|
||||
import org.talend.core.repository.model.ProjectRepositoryNode;
|
||||
import org.talend.repository.ProjectManager;
|
||||
import org.talend.repository.model.IRepositoryNode;
|
||||
import org.talend.repository.model.IRepositoryNode.ENodeType;
|
||||
import org.talend.repository.model.RepositoryNode;
|
||||
import org.talend.sdk.component.server.front.model.ConfigTypeNode;
|
||||
import org.talend.sdk.component.server.front.model.PropertyValidation;
|
||||
import org.talend.sdk.component.server.front.model.SimplePropertyDefinition;
|
||||
import org.talend.sdk.component.studio.metadata.node.TaCoKitFamilyRepositoryNode;
|
||||
import org.talend.sdk.component.studio.ui.wizard.TaCoKitConfigurationRuntimeData;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@Disabled("Instantiation of ERepositoryObjectType need eclipse.runtime env initiate")
|
||||
class TaCoKitPageBuildHelperTest {
|
||||
|
||||
@Test
|
||||
void getParameters() throws Exception {
|
||||
|
||||
this.init();
|
||||
ProjectManager.getInstance().setMainProjectBranch("studio", "main");
|
||||
RegistryProviderFactory.setDefault(new RegistryProviderOSGI(new ExtensionRegistry(null, "master", "user")));
|
||||
|
||||
TaCoKitConfigurationRuntimeData runtimeData = new TaCoKitConfigurationRuntimeData();
|
||||
|
||||
final ConfigTypeNode cfgNode = new ConfigTypeNode();
|
||||
cfgNode.setName("Test");
|
||||
cfgNode.setDisplayName("Test");
|
||||
cfgNode.setId("d29ya2RheSNXb3JrZGF5");
|
||||
cfgNode.getEdges().add("d29ya2RheSNXb3JrZGF5I2RhdGFzdG9yZSNXb3JrZGF5RGF0YVN0b3Jl");
|
||||
|
||||
TaCoKitFamilyRepositoryNode family = new TaCoKitFamilyRepositoryNode(
|
||||
null, // without parent
|
||||
null,
|
||||
cfgNode);
|
||||
|
||||
/* final RepositoryNode parentNode = new RepositoryNode(null,
|
||||
null, //project,
|
||||
ENodeType.STABLE_SYSTEM_FOLDER);
|
||||
family.setParent(parentNode);*/
|
||||
family.setType(ENodeType.STABLE_SYSTEM_FOLDER);
|
||||
runtimeData.setTaCoKitRepositoryNode(family);
|
||||
|
||||
SimplePropertyDefinition cfg = new SimplePropertyDefinition();
|
||||
cfg.setPath("configuration");
|
||||
cfg.setName("configuration");
|
||||
cfg.setDisplayName("Data connection");
|
||||
cfg.setType("OBJECT");
|
||||
cfg.setPlaceholder("configuration");
|
||||
Map<String, String> meta = new HashMap<>();
|
||||
|
||||
meta.put("ui::gridlayout::Advanced::value", "param2");
|
||||
meta.put("ui::gridlayout::Main::value", "param1");
|
||||
meta.put("documentation::value", "The connection to test datastore");
|
||||
//meta.put("action::healthcheck", "WORKDAY_HEALTH_CHECK");
|
||||
meta.put("configurationtype::name", "TestDataStore");
|
||||
meta.put("configurationtype::type", "datastore");
|
||||
meta.put("definition::parameter::index", "0");
|
||||
cfg.setMetadata(meta);
|
||||
cfgNode.getProperties().add(cfg);
|
||||
|
||||
|
||||
cfgNode.getProperties().add(new SimplePropertyDefinition("configuration.param1",
|
||||
"param1",
|
||||
"first param",
|
||||
"STRING",
|
||||
null,
|
||||
null,
|
||||
Collections.singletonMap("documentation::value", "doc param 1"),
|
||||
"place holder 1",
|
||||
null));
|
||||
cfgNode.getProperties().add(new SimplePropertyDefinition("configuration.param2",
|
||||
"param2",
|
||||
"second param",
|
||||
"STRING",
|
||||
null,
|
||||
null,
|
||||
Collections.singletonMap("documentation::value", "doc param 2"),
|
||||
"place holder 2",
|
||||
null));
|
||||
|
||||
runtimeData.setCreation(true);
|
||||
runtimeData.setReadonly(false);
|
||||
|
||||
final TaCoKitPageBuildHelper helper = new TaCoKitPageBuildHelper(runtimeData);
|
||||
helper.infer("Main");
|
||||
helper.infer("Advanced");
|
||||
helper.terminate();
|
||||
final List<IElementParameter> mainParameters = helper.getParameters("Main");
|
||||
final List<IElementParameter> advancedParameters = helper.getParameters("Advanced");
|
||||
Assertions.assertNotNull(mainParameters);
|
||||
}
|
||||
|
||||
void init() {
|
||||
try {
|
||||
final Constructor<ERepositoryObjectType> declaredConstructor =
|
||||
ERepositoryObjectType.class.getDeclaredConstructor(String.class, String.class, String.class,
|
||||
String.class, int.class, boolean.class, String.class, String[].class, boolean.class,
|
||||
String[].class, boolean[].class);
|
||||
declaredConstructor.setAccessible(true);
|
||||
ERepositoryObjectType typeObject = declaredConstructor.newInstance("repository.metadata.TaCoKit", "TaCoKit",
|
||||
"metadata/tacokit", "TACOKIT", 1, false, "TACOKIT",
|
||||
new String[] {"DI"},
|
||||
false,
|
||||
new String[] { "DI" },
|
||||
new boolean[] { true});
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
# Copyright (C) 2006-2021 Talend Inc. - www.talend.com
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
log4j.rootLogger=INFO, stdout
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.SimpleLayout
|
||||
@@ -1,318 +0,0 @@
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"family": "qa",
|
||||
"name": "basedOnTwoPrimitives",
|
||||
"properties": [
|
||||
{
|
||||
"displayName": "a",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "1"
|
||||
},
|
||||
"name": "a",
|
||||
"path": "a",
|
||||
"placeholder": "a",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"displayName": "p",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "0"
|
||||
},
|
||||
"name": "p",
|
||||
"path": "p",
|
||||
"placeholder": "p",
|
||||
"type": "STRING"
|
||||
}
|
||||
],
|
||||
"type": "suggestions"
|
||||
},
|
||||
{
|
||||
"family": "qa",
|
||||
"name": "basedOnComplex",
|
||||
"properties": [
|
||||
{
|
||||
"displayName": "ds",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "0"
|
||||
},
|
||||
"name": "ds",
|
||||
"path": "ds",
|
||||
"placeholder": "ds",
|
||||
"type": "OBJECT"
|
||||
},
|
||||
{
|
||||
"displayName": "url",
|
||||
"metadata": {},
|
||||
"name": "url",
|
||||
"path": "ds.url",
|
||||
"placeholder": "url",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"displayName": "port",
|
||||
"metadata": {},
|
||||
"name": "port",
|
||||
"path": "ds.port",
|
||||
"placeholder": "port",
|
||||
"type": "NUMBER"
|
||||
},
|
||||
{
|
||||
"displayName": "c",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "1"
|
||||
},
|
||||
"name": "c",
|
||||
"path": "c",
|
||||
"placeholder": "c",
|
||||
"type": "OBJECT"
|
||||
},
|
||||
{
|
||||
"displayName": "complexString",
|
||||
"metadata": {},
|
||||
"name": "complexString",
|
||||
"path": "c.complexString",
|
||||
"placeholder": "complexString",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"displayName": "complexInt",
|
||||
"metadata": {},
|
||||
"name": "complexInt",
|
||||
"path": "c.complexInt",
|
||||
"placeholder": "complexInt",
|
||||
"type": "NUMBER"
|
||||
}
|
||||
],
|
||||
"type": "suggestions"
|
||||
},
|
||||
{
|
||||
"family": "qa",
|
||||
"name": "checkComplex",
|
||||
"properties": [
|
||||
{
|
||||
"displayName": "s",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "0"
|
||||
},
|
||||
"name": "s",
|
||||
"path": "s",
|
||||
"placeholder": "s",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"displayName": "d",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "1"
|
||||
},
|
||||
"name": "d",
|
||||
"path": "d",
|
||||
"placeholder": "d",
|
||||
"type": "OBJECT"
|
||||
},
|
||||
{
|
||||
"displayName": "url",
|
||||
"metadata": {},
|
||||
"name": "url",
|
||||
"path": "d.url",
|
||||
"placeholder": "url",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"displayName": "port",
|
||||
"metadata": {},
|
||||
"name": "port",
|
||||
"path": "d.port",
|
||||
"placeholder": "port",
|
||||
"type": "NUMBER"
|
||||
}
|
||||
],
|
||||
"type": "validation"
|
||||
},
|
||||
{
|
||||
"family": "qa",
|
||||
"name": "checkSeveral",
|
||||
"properties": [
|
||||
{
|
||||
"displayName": "z",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "0"
|
||||
},
|
||||
"name": "z",
|
||||
"path": "z",
|
||||
"placeholder": "z",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"displayName": "yUrl",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "1"
|
||||
},
|
||||
"name": "yUrl",
|
||||
"path": "yUrl",
|
||||
"placeholder": "yUrl",
|
||||
"type": "STRING"
|
||||
},
|
||||
{
|
||||
"displayName": "xPort",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "2"
|
||||
},
|
||||
"name": "xPort",
|
||||
"path": "xPort",
|
||||
"placeholder": "xPort",
|
||||
"type": "STRING"
|
||||
}
|
||||
],
|
||||
"type": "validation"
|
||||
},
|
||||
{
|
||||
"family": "qa",
|
||||
"name": "basedOnTable",
|
||||
"properties": [
|
||||
{
|
||||
"displayName": "table",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "0"
|
||||
},
|
||||
"name": "table",
|
||||
"path": "table",
|
||||
"placeholder": "table",
|
||||
"type": "ARRAY"
|
||||
},
|
||||
{
|
||||
"displayName": "check",
|
||||
"metadata": {},
|
||||
"name": "check",
|
||||
"path": "table[].check",
|
||||
"placeholder": "check",
|
||||
"type": "BOOLEAN"
|
||||
},
|
||||
{
|
||||
"displayName": "number",
|
||||
"metadata": {},
|
||||
"name": "table[].number",
|
||||
"path": "number",
|
||||
"placeholder": "number",
|
||||
"type": "NUMBER"
|
||||
},
|
||||
{
|
||||
"displayName": "operator",
|
||||
"metadata": {},
|
||||
"name": "table[].operator",
|
||||
"path": "operator",
|
||||
"placeholder": "operator",
|
||||
"type": "ENUM"
|
||||
},
|
||||
{
|
||||
"displayName": "strColumn",
|
||||
"metadata": {},
|
||||
"name": "table[].strColumn",
|
||||
"path": "strColumn",
|
||||
"placeholder": "strColumn",
|
||||
"type": "STRING"
|
||||
}
|
||||
],
|
||||
"type": "suggestions"
|
||||
}
|
||||
],
|
||||
"name": "suggestion",
|
||||
"nodes": [
|
||||
{
|
||||
"fieldType": "TEXT",
|
||||
"property": {
|
||||
"delegate": {
|
||||
"displayName": "basedOnTwoPrimitives",
|
||||
"metadata": {
|
||||
"action::suggestions": "basedOnTwoPrimitives",
|
||||
"action::suggestions::parameters": "primitive,another",
|
||||
"action::validation": "checkSeveral",
|
||||
"action::validation::parameters": ".,datastore/url,datastore/port"
|
||||
},
|
||||
"name": "basedOnTwoPrimitives",
|
||||
"path": "conf.basedOnTwoPrimitives",
|
||||
"type": "STRING"
|
||||
}
|
||||
},
|
||||
"root": false,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"fieldType": "TEXT",
|
||||
"property": {
|
||||
"delegate": {
|
||||
"displayName": "basedOnComplex",
|
||||
"metadata": {
|
||||
"action::suggestions": "basedOnComplex",
|
||||
"action::suggestions::parameters": "datastore,complex",
|
||||
"action::validation": "checkComplex",
|
||||
"action::validation::parameters": ".,datastore"
|
||||
},
|
||||
"name": "basedOnComplex",
|
||||
"path": "conf.basedOnComplex",
|
||||
"type": "STRING"
|
||||
}
|
||||
},
|
||||
"root": false,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"fieldType": "TEXT",
|
||||
"property": {
|
||||
"delegate": {
|
||||
"displayName": "basedOnTable",
|
||||
"metadata": {
|
||||
"action::suggestions": "basedOnTable",
|
||||
"action::suggestions::parameters": "table"
|
||||
},
|
||||
"name": "basedOnTable",
|
||||
"path": "conf.basedOnTable",
|
||||
"type": "STRING"
|
||||
}
|
||||
},
|
||||
"root": false,
|
||||
"children": []
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
|
||||
],
|
||||
"settings": [
|
||||
{
|
||||
"name": "conf.primitive",
|
||||
"value": "primitive value"
|
||||
},
|
||||
{
|
||||
"name": "conf.another",
|
||||
"value": "another value"
|
||||
},
|
||||
{
|
||||
"name": "conf.basedOnTable",
|
||||
"value": "based on table"
|
||||
},
|
||||
{
|
||||
"name": "conf.basedOnTwoPrimitives",
|
||||
"value": "based on 2 primitives"
|
||||
},
|
||||
{
|
||||
"name": "conf.basedOnComplex",
|
||||
"value": "based on complex"
|
||||
},
|
||||
{
|
||||
"name": "conf.complex.complexString",
|
||||
"value": "complex string"
|
||||
},
|
||||
{
|
||||
"name": "conf.complex.complexInt",
|
||||
"value": "-1"
|
||||
},
|
||||
{
|
||||
"name": "conf.datastore.url",
|
||||
"value": "http://initial.url"
|
||||
},
|
||||
{
|
||||
"name": "conf.datastore.port",
|
||||
"value": "8080"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
{
|
||||
"actions": [
|
||||
{
|
||||
"family": "qa",
|
||||
"name": "updatableConfig",
|
||||
"properties": [
|
||||
{
|
||||
"displayName": "c",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "0"
|
||||
},
|
||||
"name": "c",
|
||||
"path": "c",
|
||||
"placeholder": "c",
|
||||
"type": "ENUM"
|
||||
},
|
||||
{
|
||||
"displayName": "s",
|
||||
"metadata": {
|
||||
"definition::parameter::index": "1"
|
||||
},
|
||||
"name": "s",
|
||||
"path": "s",
|
||||
"placeholder": "s",
|
||||
"type": "STRING"
|
||||
}
|
||||
],
|
||||
"type": "update"
|
||||
}
|
||||
],
|
||||
|
||||
"name": "update",
|
||||
|
||||
"nodes": [
|
||||
{
|
||||
"fieldType": "TEXT",
|
||||
"property": {
|
||||
"delegate": {
|
||||
"displayName": "updatableConfig",
|
||||
"metadata": {
|
||||
"action::update": "updatableConfig",
|
||||
"action::update::after": "",
|
||||
"action::update::parameters": "constant,str"
|
||||
},
|
||||
"name": "updatableConfig",
|
||||
"path": "conf.updatableConfig",
|
||||
"type": "OBJECT"
|
||||
}
|
||||
},
|
||||
"root": false,
|
||||
"children": [
|
||||
{
|
||||
"fieldType": "TEXT",
|
||||
"property": {
|
||||
"delegate": {
|
||||
"displayName": "nestedConfig",
|
||||
"metadata": {},
|
||||
"name": "nestedConfig",
|
||||
"path": "conf.updatableConfig.nestedConfig",
|
||||
"type": "OBJECT"
|
||||
}
|
||||
},
|
||||
"root": false,
|
||||
"children": [
|
||||
{
|
||||
"fieldType": "TEXT",
|
||||
"property": {
|
||||
"delegate": {
|
||||
"displayName": "str1",
|
||||
"metadata": {},
|
||||
"name": "str1",
|
||||
"path": "conf.updatableConfig.nestedConfig.str1",
|
||||
"type": "STRING"
|
||||
}
|
||||
},
|
||||
"root": false,
|
||||
"children": []
|
||||
},
|
||||
{
|
||||
"fieldType": "TEXT",
|
||||
"property": {
|
||||
"delegate": {
|
||||
"displayName": "str2",
|
||||
"metadata": {},
|
||||
"name": "str2",
|
||||
"path": "conf.updatableConfig.nestedConfig.str2",
|
||||
"type": "STRING"
|
||||
}
|
||||
},
|
||||
"root": false,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"fieldType": "TEXT",
|
||||
"property": {
|
||||
"delegate": {
|
||||
"displayName": "str",
|
||||
"metadata": {},
|
||||
"name": "str",
|
||||
"path": "conf.updatableConfig.str",
|
||||
"type": "STRING"
|
||||
}
|
||||
},
|
||||
"root": false,
|
||||
"children": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
|
||||
],
|
||||
"settings": [
|
||||
{
|
||||
"name": "conf.constant",
|
||||
"value": "LESS"
|
||||
},
|
||||
{
|
||||
"name": "conf.str",
|
||||
"value": "Hello world!"
|
||||
},
|
||||
{
|
||||
"name": "conf.updatableConfig.str",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "conf.updatableConfig.nestedConfig.str1",
|
||||
"value": ""
|
||||
},
|
||||
{
|
||||
"name": "conf.updatableConfig.nestedConfig.str2",
|
||||
"value": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"str" : "1st level str value",
|
||||
"nestedConfig" : {
|
||||
"str1" : "2nd level str1 value",
|
||||
"str2" : "2nd level str2 value"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user