> getVersions) {
+ this.getVersions = getVersions;
+ }
+}
diff --git a/src/main/resources/correlation-descriptions/TemplateSaveFrame.html b/src/main/resources/correlation-descriptions/TemplateSaveFrame.html
new file mode 100644
index 0000000..be33f6a
--- /dev/null
+++ b/src/main/resources/correlation-descriptions/TemplateSaveFrame.html
@@ -0,0 +1,56 @@
+
+
+
+
+
+ Help Guide: Saving Your Correlation Template
+
+
+
+Help Guide: Saving Your Correlation Template
+This guide assists you in navigating the form to save your template. The form consists of two main tabs:
+
+ - Version's Information: Details specific to the current version.
+ - Template's Information: General details about the template itself.
+
+
+1. Version's Information Tab:
+
+ - Repository: Choose a repository from the combo box. This determines where your template will be saved. Default is "local" for your local storage. If you've set up BlazeMeter, relevant workspaces will appear here. Only writable repositories are displayed.
+ - Template: Lists available templates in the selected repository. Choosing a template will update the Versions combo. If a needed template isn't listed, manually inputting it will create a new one.
+ - Versions: Shows template versions available locally. Picking a version auto-suggests a new version number in the "New Version" field, but there's no strict link between them. It's just a guide.
+ - New Version: Suggests a version based on the selected one. It's recommended to use Semantic versioning for template versions.
+ - Changes: Document the differences between this and the previous version. Maintaining a change log is advisable.
+
+
+2. Template's Information Tab:
+
+ - Template Description: A space to describe the template's purpose and functionality. HTML tags are permitted.
+ - Author's Name & Link: Self-explanatory.
+ - Dependencies: Add relevant dependency links for your template.
+
+
+Saving Your Template:
+ Click on the 'Save' button. If it's grayed out, a required field needs correcting. Fields with errors will have a red note underneath pinpointing the issue.
+
+
+
diff --git a/src/test/java/com/blazemeter/jmeter/correlation/CorrelationProxyControlBuilder.java b/src/test/java/com/blazemeter/jmeter/correlation/CorrelationProxyControlBuilder.java
index 9887931..ad1e8d8 100644
--- a/src/test/java/com/blazemeter/jmeter/correlation/CorrelationProxyControlBuilder.java
+++ b/src/test/java/com/blazemeter/jmeter/correlation/CorrelationProxyControlBuilder.java
@@ -63,8 +63,9 @@ public CorrelationProxyControl build() {
repositoriesRegistry = repositoriesRegistry != null ?
repositoriesRegistry
: new CorrelationTemplatesRepositoriesConfiguration(configuration);
- CorrelationProxyControl model = new CorrelationProxyControl(registry, repositoriesRegistry,
- configuration, engine, templatesRegistry);
+
+ CorrelationProxyControl model =
+ new CorrelationProxyControl(registry, repositoriesRegistry, configuration, engine);
model.setName("bzm - Correlation Recorder");
if (target != null) {
diff --git a/src/test/java/com/blazemeter/jmeter/correlation/CorrelationProxyControlTest.java b/src/test/java/com/blazemeter/jmeter/correlation/CorrelationProxyControlTest.java
index de128b6..c8b701e 100644
--- a/src/test/java/com/blazemeter/jmeter/correlation/CorrelationProxyControlTest.java
+++ b/src/test/java/com/blazemeter/jmeter/correlation/CorrelationProxyControlTest.java
@@ -6,6 +6,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+
import com.blazemeter.jmeter.correlation.core.CorrelationEngine;
import com.blazemeter.jmeter.correlation.core.CorrelationRule;
import com.blazemeter.jmeter.correlation.core.RulesGroup;
@@ -150,7 +151,7 @@ public void shouldBuildCorrelationRulesWhenOnSaveTemplateWithRulesWithoutCorrela
model.onSaveTemplate(BASE_TEMPLATE_BUILDER);
//Its been called once since only save the CorrelationTemplate once after building it
- verify(correlationComponentsRegistry, only()).save(prepareExpectedTemplate(groups));
+ verify(localConfiguration, only()).saveTemplate(prepareExpectedTemplate(groups));
}
private List prepareRulesWithoutCorrelationExtractors() {
@@ -173,8 +174,8 @@ public void shouldBuildCorrelationRulesWhenOnSaveTemplateWithRulesWithoutCorrela
model.setCorrelationGroups(groups);
model.onSaveTemplate(BASE_TEMPLATE_BUILDER);
- //Its been called once since only save the CorrelationTemplate once after building it
- verify(correlationComponentsRegistry, only()).save(prepareExpectedTemplate(groups));
+ //It's been called once since only save the CorrelationTemplate once after building it
+ verify(localConfiguration, only()).saveTemplate(prepareExpectedTemplate(groups));
}
private List prepareGroupOfRulesWithoutCorrelationReplacements() {
@@ -189,7 +190,7 @@ private List prepareGroupOfRulesWithoutCorrelationReplacements() {
@Test
public void shouldAppendLoadedTemplateWhenOnLoadTemplate() throws IOException {
- when(correlationComponentsRegistry.findByID(LOCAL_REPOSITORY_ID, TEMPLATE_ID, TEMPLATE_VERSION))
+ when(localConfiguration.findById(LOCAL_REPOSITORY_ID, TEMPLATE_ID, TEMPLATE_VERSION))
.thenReturn(Optional.of(testTemplate));
when(testTemplate.getResponseFilters())
@@ -243,7 +244,7 @@ private String buildArrayFromListOfStrings(String... strings) {
@Test
public void shouldRemoveRepeatedElementsWhenWhenOnLoadTemplate() throws IOException {
- when(correlationComponentsRegistry.findByID(LOCAL_REPOSITORY_ID, TEMPLATE_ID, TEMPLATE_VERSION))
+ when(localConfiguration.findById(LOCAL_REPOSITORY_ID, TEMPLATE_ID, TEMPLATE_VERSION))
.thenReturn(Optional.of(testTemplate));
when(testTemplate.getResponseFilters()).thenReturn(
diff --git a/src/test/java/com/blazemeter/jmeter/correlation/core/automatic/CorrelationWizardIT.java b/src/test/java/com/blazemeter/jmeter/correlation/core/automatic/CorrelationWizardIT.java
index 7aa4235..79519a9 100644
--- a/src/test/java/com/blazemeter/jmeter/correlation/core/automatic/CorrelationWizardIT.java
+++ b/src/test/java/com/blazemeter/jmeter/correlation/core/automatic/CorrelationWizardIT.java
@@ -4,9 +4,7 @@
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplateVersions;
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplatesRepositoriesConfiguration;
import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplatesRepository;
-import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplatesRepositoryConfiguration;
import com.blazemeter.jmeter.correlation.core.templates.LocalConfiguration;
-import com.blazemeter.jmeter.correlation.core.templates.LocalCorrelationTemplatesRepositoriesRegistry;
import com.blazemeter.jmeter.correlation.core.templates.repository.RepositoryManager;
import com.blazemeter.jmeter.correlation.gui.automatic.CorrelationWizard;
import java.awt.Dimension;
@@ -68,12 +66,6 @@ public static void main(String[] args) {
String path = "/Users/abstracta/testing/jmeter-siebel-plugin/jmeters/apache-jmeter-5.5/";
LocalConfiguration configuration = new LocalConfiguration(path, true);
configuration.setupRepositoryManagers();
-
- LocalCorrelationTemplatesRepositoriesRegistry local =
- new LocalCorrelationTemplatesRepositoriesRegistry(configuration);
- List repositories1 = local.getRepositories();
-
-
/*
*
* LocalConfiguration localConfiguration = new LocalConfiguration(folder.getRoot().getPath(), true);
@@ -86,14 +78,11 @@ public static void main(String[] args) {
prepareExpectedLocalRepository();
* */
- List repositories =
- configuration.getRepositories();
-
-
- for (CorrelationTemplatesRepositoryConfiguration repository : repositories) {
+ List repositories = configuration.getRepositories();
+ for (CorrelationTemplatesRepository repository : repositories) {
+ System.out.println(repository.getName());
RepositoryManager manager = configuration.getRepositoryManager(repository.getName());
- Map templateVersions = manager.getTemplateVersions();
- System.out.println(templateVersions);
+ Map versions = manager.getTemplateVersions();
}
history = new CorrelationHistory();
diff --git a/src/test/java/com/blazemeter/jmeter/correlation/core/templates/LocalConfigurationTest.java b/src/test/java/com/blazemeter/jmeter/correlation/core/templates/LocalConfigurationTest.java
index 742bb6e..39046d0 100644
--- a/src/test/java/com/blazemeter/jmeter/correlation/core/templates/LocalConfigurationTest.java
+++ b/src/test/java/com/blazemeter/jmeter/correlation/core/templates/LocalConfigurationTest.java
@@ -39,7 +39,6 @@
@RunWith(MockitoJUnitRunner.class)
public class LocalConfigurationTest {
- private static final String LOCAL_REPOSITORY_NAME = "local";
private static final String VERSION_ONE = "1.0";
private static final String DUMMY_FILE_VERSION_ONE = "dummy-1.0.jar";
private static final String SIEBEL_REPO_NAME = "siebel";
@@ -68,12 +67,44 @@ public class LocalConfigurationTest {
private CorrelationTemplatesRepositoryConfiguration repositoryWithInstalledTemplates;
@Mock
private CorrelationTemplatesRepositoryConfiguration localRepositoryConfiguration;
+ @Mock
+ private CorrelationTemplatesRepository expectedSiebelRepository;
+ @Mock
+ private CorrelationTemplatesRepository expectedCentralRepository;
private final WireMockServer wireMockServer = new WireMockServer(wireMockConfig().dynamicPort());
private LocalConfiguration configuration;
private String dependenciesFolder;
+ private static final String TEMPLATE_FILE_SUFFIX = "template.json";
+
+ private static final String REPOSITORY_FILE_SUFFIX = "repository.json";
+
+ private static final String LOCAL_REPOSITORY_NAME = "local";
+ private static final String LOCAL_REPOSITORY_DISPLAY_NAME = "Local";
+
+ private static final String CENTRAL_REPOSITORY_NAME = "central";
+ private static final String CENTRAL_REPOSITORY_DISPLAY_NAME = "GitHub's Central";
+
+ private static final String SIEBEL_TEMPLATE_REFERENCE_NAME = "siebel";
+ private static final String WORDPRESS_TEMPLATE_REFERENCE_NAME = "wordpress";
+ private static final String TEMPLATE_VERSION_TWO = "1.1";
+ private static final String TEMPLATE_VERSION_ONE = "1.0";
+
+ private static final String TEMPLATE_VERSION_THREE = "0.1-alpha";
+
+ private static final String CORRELATION_TEMPLATES_REPOSITORY_NAME =
+ "CorrelationTemplatesRepository";
+
+ private static final String SIEBEL_TEMPLATE_VERSION_TWO_NAME =
+ SIEBEL_TEMPLATE_REFERENCE_NAME + "-" + TEMPLATE_VERSION_TWO + "-" + TEMPLATE_FILE_SUFFIX;
+ private static final String SIEBEL_TEMPLATE_VERSION_ONE_NAME =
+ SIEBEL_TEMPLATE_REFERENCE_NAME + "-" + TEMPLATE_VERSION_ONE + "-" + TEMPLATE_FILE_SUFFIX;
+
+ private static final String WORDPRESS_TEMPLATE_VERSION_ONE_NAME =
+ WORDPRESS_TEMPLATE_REFERENCE_NAME + "-" + TEMPLATE_VERSION_ONE + "-" + TEMPLATE_FILE_SUFFIX;
@Before
public void setUp() {
+ LocalConfiguration.installDefaultFiles(folder.getRoot().getPath());
configuration = new LocalConfiguration(folder.getRoot().getPath(), true);
configuration.setupRepositoryManagers();
when(firstRepository.getName()).thenReturn(FIRST_REPO_NAME);
@@ -81,6 +112,7 @@ public void setUp() {
when(localRepository.getName()).thenReturn(LOCAL_REPOSITORY_NAME);
configuration.addRepository(firstRepository.getName(), firstRepositoryURL);
dependenciesFolder = folder.getRoot().getAbsolutePath() + "/lib/";
+ prepareExpectedLocalRepository();
}
@After
@@ -89,6 +121,20 @@ public void tearDown() {
wireMockServer.stop();
}
}
+ private void prepareExpectedLocalRepository() {
+ when(expectedSiebelRepository.getValues()).thenReturn(
+ CORRELATION_TEMPLATES_REPOSITORY_NAME + "{name='" + LOCAL_REPOSITORY_NAME
+ + "', displayName='" + LOCAL_REPOSITORY_DISPLAY_NAME
+ + "', templatesVersions={" + SIEBEL_TEMPLATE_REFERENCE_NAME +
+ "=CorrelationTemplateVersions {versions=[" + TEMPLATE_VERSION_ONE + "]}}}");
+
+ when(expectedCentralRepository.getValues()).thenReturn(
+ CORRELATION_TEMPLATES_REPOSITORY_NAME + "{name='" + CENTRAL_REPOSITORY_NAME
+ + "', displayName='" + CENTRAL_REPOSITORY_DISPLAY_NAME
+ + "', templatesVersions={" + WORDPRESS_TEMPLATE_REFERENCE_NAME +
+ "=CorrelationTemplateVersions {versions=[" + TEMPLATE_VERSION_THREE + "]}}}");
+
+ }
public void configureWireMockServer() {
wireMockServer.start();
@@ -374,4 +420,24 @@ public void shouldReturnErrorWhenCheckRepositoryURlWithNoJsonFile() {
".\n"
+ " Error: URL should lead to .json file"), errors);
}
+
+ @Test
+ public void shouldReturnLocalCorrelationTemplatesRepositoriesWhenGetRepositories() {
+ assertEquals(getRepositoriesNames(prepareExpectedLocalRepositories()),
+ getRepositoriesNames(configuration.getRepositories()));
+ }
+
+ private List getRepositoriesNames(List repositories) {
+ return repositories.stream().map(CorrelationTemplatesRepository::getValues)
+ .collect(Collectors.toList());
+ }
+
+ private List prepareExpectedLocalRepositories() {
+ List expectedLocalRepositories = new ArrayList<>();
+ expectedLocalRepositories.add(expectedCentralRepository);
+ expectedLocalRepositories.add(expectedSiebelRepository);
+
+ return expectedLocalRepositories;
+ }
+
}
diff --git a/src/test/java/com/blazemeter/jmeter/correlation/core/templates/LocalCorrelationTemplatesRepositoriesRegistryTest.java b/src/test/java/com/blazemeter/jmeter/correlation/core/templates/LocalCorrelationTemplatesRepositoriesRegistryTest.java
index 8f96151..1f61f94 100644
--- a/src/test/java/com/blazemeter/jmeter/correlation/core/templates/LocalCorrelationTemplatesRepositoriesRegistryTest.java
+++ b/src/test/java/com/blazemeter/jmeter/correlation/core/templates/LocalCorrelationTemplatesRepositoriesRegistryTest.java
@@ -3,6 +3,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
+
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
@@ -27,8 +28,6 @@ public class LocalCorrelationTemplatesRepositoriesRegistryTest {
private static final String TEMPLATE_FILE_SUFFIX = "template.json";
private static final String REPOSITORY_FILE_SUFFIX = "repository.json";
private static final String EXTERNAL_REPOSITORY_NAME = "base";
- private static final String LOCAL_REPOSITORY_NAME = "local";
- private static final String CENTRAL_REPOSITORY_NAME = "central";
private static final String SIEBEL_TEMPLATE_REFERENCE_NAME = "siebel";
private static final String WORDPRESS_TEMPLATE_REFERENCE_NAME = "wordpress";
@@ -38,8 +37,6 @@ public class LocalCorrelationTemplatesRepositoriesRegistryTest {
private static final String TEMPLATE_VERSION_TWO = "1.1";
private static final String TEMPLATE_VERSION_ONE = "1.0";
- private static final String TEMPLATE_VERSION_THREE = "0.1-alpha";
-
private static final String SIEBEL_TEMPLATE_VERSION_TWO_NAME =
SIEBEL_TEMPLATE_REFERENCE_NAME + "-" + TEMPLATE_VERSION_TWO + "-" + TEMPLATE_FILE_SUFFIX;
private static final String SIEBEL_TEMPLATE_VERSION_ONE_NAME =
@@ -54,14 +51,11 @@ public class LocalCorrelationTemplatesRepositoriesRegistryTest {
public TemporaryFolder folder = new TemporaryFolder();
@Mock
private CorrelationTemplatesRepository expectedBaseRepository;
- @Mock
- private CorrelationTemplatesRepository expectedSiebelRepository;
- @Mock
- private CorrelationTemplatesRepository expectedCentralRepository;
private LocalCorrelationTemplatesRepositoriesRegistry local;
@Before
public void setup() throws IOException {
+ LocalConfiguration.installDefaultFiles(folder.getRoot().getPath());
LocalConfiguration localConfiguration =
new LocalConfiguration(folder.getRoot().getPath(), true);
localConfiguration.setupRepositoryManagers();
@@ -74,25 +68,15 @@ public void setup() throws IOException {
}
private void prepareExpectedLocalRepository() {
- when(expectedSiebelRepository.getValues()).thenReturn(
- CORRELATION_TEMPLATES_REPOSITORY_NAME + "{name='" + LOCAL_REPOSITORY_NAME
- + "', templatesVersions={" + SIEBEL_TEMPLATE_REFERENCE_NAME +
- "=CorrelationTemplateReference{versions=[" + TEMPLATE_VERSION_ONE + "]}}}");
-
- when(expectedCentralRepository.getValues()).thenReturn(
- CORRELATION_TEMPLATES_REPOSITORY_NAME + "{name='" + CENTRAL_REPOSITORY_NAME
- + "', templatesVersions={" + WORDPRESS_TEMPLATE_REFERENCE_NAME +
- "=CorrelationTemplateReference{versions=[" + TEMPLATE_VERSION_THREE + "]}}}");
-
when(expectedBaseRepository.getName()).thenReturn(EXTERNAL_REPOSITORY_NAME);
when(expectedBaseRepository.getValues()).thenReturn(
CORRELATION_TEMPLATES_REPOSITORY_NAME + "{name='" + EXTERNAL_REPOSITORY_NAME
- + "', templatesVersions={"
+ + "', displayName='null', templatesVersions={"
+ SIEBEL_TEMPLATE_REFERENCE_NAME
- + "=CorrelationTemplateReference{versions=[" + TEMPLATE_VERSION_ONE
+ + "=CorrelationTemplateVersions {versions=[" + TEMPLATE_VERSION_ONE
+ ", " + TEMPLATE_VERSION_TWO + "]}, "
+ WORDPRESS_TEMPLATE_REFERENCE_NAME
- + "=CorrelationTemplateReference{versions=[" + TEMPLATE_VERSION_ONE
+ + "=CorrelationTemplateVersions {versions=[" + TEMPLATE_VERSION_ONE
+ "]}}}");
}
@@ -124,25 +108,6 @@ private List getGeneratedFilesNames(String repositoryName) {
.collect(Collectors.toList());
}
- @Test
- public void shouldReturnLocalCorrelationTemplatesRepositoriesWhenGetRepositories() {
- assertEquals(getRepositoriesNames(prepareExpectedLocalRepositories()),
- getRepositoriesNames(local.getRepositories()));
- }
-
- private List getRepositoriesNames(List repositories) {
- return repositories.stream().map(CorrelationTemplatesRepository::getValues)
- .collect(Collectors.toList());
- }
-
- private List prepareExpectedLocalRepositories() {
- List expectedLocalRepositories = new ArrayList<>();
- expectedLocalRepositories.add(expectedCentralRepository);
- expectedLocalRepositories.add(expectedSiebelRepository);
- expectedLocalRepositories.add(expectedBaseRepository);
-
- return expectedLocalRepositories;
- }
@Test
public void shouldFindRepositoryByIdWhenFind() {
diff --git a/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/TemplateDependenciasTableIT.java b/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/TemplateDependenciasTableIT.java
new file mode 100644
index 0000000..c7d6927
--- /dev/null
+++ b/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/TemplateDependenciasTableIT.java
@@ -0,0 +1,104 @@
+package com.blazemeter.jmeter.correlation.gui.templates;
+
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.mockito.Mockito.when;
+import com.blazemeter.jmeter.correlation.SwingTestRunner;
+import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplateDependency;
+import com.blazemeter.jmeter.correlation.core.templates.CorrelationTemplatesRegistryHandler;
+import com.blazemeter.jmeter.correlation.core.templates.Template;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import org.assertj.swing.fixture.FrameFixture;
+import org.assertj.swing.fixture.JButtonFixture;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+
+@RunWith(SwingTestRunner.class)
+public class TemplateDependenciasTableIT {
+
+ private static final String TEMPLATE_DESCRIPTION = "TestDescription";
+ private static final String TEMPLATE_VERSION = "1.0.0";
+ private static final String TEMPLATE_ID = "TestID";
+ private FrameFixture frame;
+ private TemplateDependenciesTable templateSaveFrame;
+ private Set lastLoadedTemplates;
+ @Mock
+ private CorrelationTemplatesRegistryHandler templatesRegistry;
+ @Mock
+ private CorrelationTemplateDependency firstDependency;
+ @Mock
+ private CorrelationTemplateDependency secondDependency;
+ @Mock
+ private CorrelationTemplateDependency thirdDependency;
+ @Mock
+ private Template registeredTemplate;
+ @Mock
+ private Template lastLoadedTemplate;
+
+ @Test
+ public void shouldAddDependencyWhenAddPressed() {
+ openAdvancedSectionPanel();
+ findDependencyAddButton().click();
+ assertThat(templateSaveFrame.getDependencies()).isNotEmpty();
+ }
+
+ private void openAdvancedSectionPanel() {
+ frame.button("-collapsiblePanel-header-collapseButton").click();
+ }
+
+ private JButtonFixture findDependencyAddButton() {
+ return frame.button("addButton");
+ }
+
+ @Test
+ public void shouldClearRulesWhenClearPressed() {
+ openAdvancedSectionPanel();
+ findDependencyAddButton().click();
+ frame.button("clearButton").click();
+ assertThat(templateSaveFrame.getDependencies()).isEmpty();
+ }
+
+ @Test
+ public void shouldSetDependenciesWhenSetDependencies() {
+ List dependencies = buildExpectedDependencies();
+ templateSaveFrame.setDependencies(dependencies);
+ assertThat(templateSaveFrame.getDependencies().size()).isEqualTo(
+ dependencies.size());
+ }
+
+ private List buildExpectedDependencies() {
+ return Arrays.asList(firstDependency, secondDependency);
+ }
+
+
+
+ private void prepareRegisteredTemplate() {
+ when(registeredTemplate.getId()).thenReturn(TEMPLATE_ID);
+ when(registeredTemplate.getVersion()).thenReturn(TEMPLATE_VERSION);
+ when(registeredTemplate.getDescription()).thenReturn(TEMPLATE_DESCRIPTION);
+ when(registeredTemplate.getDependencies())
+ .thenReturn(Arrays.asList(firstDependency, secondDependency));
+ }
+
+ private void prepareDependencies() {
+ prepareDependencyAndUrlValidity(firstDependency, 1, true);
+ prepareDependencyAndUrlValidity(secondDependency, 1, true);
+ }
+
+ private void prepareDependencyAndUrlValidity(CorrelationTemplateDependency dependency,
+ int number,
+ boolean urlValidity) {
+ String dependencyName = "Dependency" + number;
+ String dependencyVersion = number + ".0";
+ String dependencyURL = "ulr" + number;
+
+ when(dependency.getName()).thenReturn(dependencyName);
+ when(dependency.getVersion()).thenReturn(dependencyVersion);
+ when(dependency.getUrl()).thenReturn(dependencyURL);
+ when(templatesRegistry
+ .isValidDependencyURL(dependencyURL, dependencyName, dependencyVersion))
+ .thenReturn(urlValidity);
+ }
+}
diff --git a/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/TemplateManagerDisplaySaveFrameIT.java b/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/TemplateManagerDisplaySaveFrameIT.java
index d1a7757..2162063 100644
--- a/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/TemplateManagerDisplaySaveFrameIT.java
+++ b/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/TemplateManagerDisplaySaveFrameIT.java
@@ -12,13 +12,12 @@
import com.blazemeter.jmeter.correlation.core.templates.Template;
import com.blazemeter.jmeter.correlation.core.templates.Template.Builder;
import java.awt.Container;
+import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
-import java.util.Set;
import java.util.function.Consumer;
import javax.swing.JPanel;
import org.assertj.swing.fixture.FrameFixture;
@@ -56,14 +55,16 @@ public class TemplateManagerDisplaySaveFrameIT {
private CorrelationTemplateDependency thirdDependency;
@Mock
private Consumer lastTemplateHandler;
+ @Mock
+ private BufferedImage snapshot;
private TemplateSaveFrame templateSaveFrame;
- private Set lastLoadedTemplates;
+ private List lastLoadedTemplates;
@Before
public void setup() {
templateSaveFrame = new TemplateSaveFrame(templatesRegistry, null,
- lastTemplateHandler, new JPanel());
- lastLoadedTemplates = new HashSet<>(Collections.singletonList(registeredTemplate));
+ snapshot, lastTemplateHandler, new JPanel());
+ lastLoadedTemplates = Collections.singletonList(registeredTemplate);
Container contentPane = templateSaveFrame.getContentPane();
frame = showInFrame(contentPane);
}
@@ -145,10 +146,14 @@ private void requireMessage(String message) {
@Test
public void shouldShowTemplateIDWhenSetLoadedTemplatesWithOneLoadedTemplate() {
prepareRegisteredTemplate();
- templateSaveFrame.setLoadedTemplates(lastLoadedTemplates);
+ templateSaveFrame.setLoadedTemplates(getLastLoadedTemplate());
assertThat(findTemplateIdField().text()).isEqualTo(TEMPLATE_ID);
}
+ private Template getLastLoadedTemplate() {
+ return lastLoadedTemplates.get(lastLoadedTemplates.size() - 1);
+ }
+
private void prepareRegisteredTemplate() {
when(registeredTemplate.getId()).thenReturn(TEMPLATE_ID);
when(registeredTemplate.getVersion()).thenReturn(TEMPLATE_VERSION);
@@ -161,14 +166,14 @@ private void prepareRegisteredTemplate() {
@Test
public void shouldSetupVersionFieldWhenSetLoadTemplatesWithOneLoadedTemplate() {
prepareRegisteredTemplate();
- templateSaveFrame.setLoadedTemplates(lastLoadedTemplates);
+ templateSaveFrame.setLoadedTemplates(getLastLoadedTemplate());
assertThat(findTemplateVersionField().text()).isEqualTo(TEMPLATE_VERSION);
}
@Test
public void shouldSetupDescriptionFieldWhenSetLoadTemplatesWithOneLoadedTemplate() {
prepareRegisteredTemplate();
- templateSaveFrame.setLoadedTemplates(lastLoadedTemplates);
+ templateSaveFrame.setLoadedTemplates(getLastLoadedTemplate());
assertThat(findTemplateDescriptionField().text()).isEqualTo(TEMPLATE_DESCRIPTION);
}
@@ -176,7 +181,7 @@ public void shouldSetupDescriptionFieldWhenSetLoadTemplatesWithOneLoadedTemplate
public void shouldShowTemplateIDEmptyWhenSetLoadedTemplatesWithMultipleLoadedTemplate() {
prepareRegisteredTemplate();
lastLoadedTemplates.add(lastLoadedTemplate);
- templateSaveFrame.setLoadedTemplates(lastLoadedTemplates);
+ templateSaveFrame.setLoadedTemplates(getLastLoadedTemplate());
assertThat(findTemplateIdField().text()).isEmpty();
}
@@ -184,7 +189,7 @@ public void shouldShowTemplateIDEmptyWhenSetLoadedTemplatesWithMultipleLoadedTem
public void shouldShowTemplateDescriptionEmptyWhenSetLoadedTemplatesWithMultipleLoadedTemplate() {
prepareRegisteredTemplate();
lastLoadedTemplates.add(lastLoadedTemplate);
- templateSaveFrame.setLoadedTemplates(lastLoadedTemplates);
+ templateSaveFrame.setLoadedTemplates(getLastLoadedTemplate());
assertThat(findTemplateDescriptionField().text()).isEmpty();
}
@@ -209,29 +214,6 @@ private JButtonFixture findDependencyAddButton() {
return frame.button("addButton");
}
- @Test
- public void shouldAddDependencyWhenAddPressed() {
- openAdvancedSectionPanel();
- findDependencyAddButton().click();
- assertThat(templateSaveFrame.getDependencies()).isNotEmpty();
- }
-
- @Test
- public void shouldClearRulesWhenClearPressed() {
- openAdvancedSectionPanel();
- findDependencyAddButton().click();
- frame.button("clearButton").click();
- assertThat(templateSaveFrame.getDependencies()).isEmpty();
- }
-
- @Test
- public void shouldSetDependenciesWhenSetDependencies() {
- List dependencies = buildExpectedDependencies();
- templateSaveFrame.setDependencies(dependencies);
- assertThat(templateSaveFrame.getDependencies().size()).isEqualTo(
- dependencies.size());
- }
-
private List buildExpectedDependencies() {
return Arrays.asList(firstDependency, secondDependency);
}
@@ -287,17 +269,6 @@ public void shouldDisplayWarningMessageWhenSaveWithInvalidUrlDependency() {
+ "Check the logs for more information.");
}
- @Test
- public void shouldLoadMultipleDependenciesWhenLoadWithMultipleLoadedTemplates() {
- prepareDependencies();
- prepareRegisteredTemplate();
- when(lastLoadedTemplate.getDependencies())
- .thenReturn(Collections.singletonList(thirdDependency));
- lastLoadedTemplates.add(lastLoadedTemplate);
- templateSaveFrame.setLoadedTemplates(lastLoadedTemplates);
- assertThat(templateSaveFrame.getDependencies().size()).isEqualTo(3);
- }
-
@Test
public void shouldDisableSaveButtonWhenFormHasErrors() {
findTemplateIdField().setText(TEMPLATE_ID + " /");
@@ -393,4 +364,15 @@ public void shouldEnableSaveButtonWhenFillFieldWithValidTexts() {
findSaveButton().focus();
assertThat(findSaveButton().isEnabled()).isTrue();
}
+
+ @Test
+ public void shouldLoadMultipleDependenciesWhenLoadWithMultipleLoadedTemplates() {
+ prepareDependencies();
+ prepareRegisteredTemplate();
+ when(lastLoadedTemplate.getDependencies())
+ .thenReturn(Collections.singletonList(thirdDependency));
+ lastLoadedTemplates.add(lastLoadedTemplate);
+ templateSaveFrame.setLoadedTemplates(getLastLoadedTemplate());
+ assertThat(templateSaveFrame.getDependenciesTable().getDependencies().size()).isEqualTo(3);
+ }
}
diff --git a/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/ValidationTest.java b/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/ValidationTest.java
deleted file mode 100644
index 069a891..0000000
--- a/src/test/java/com/blazemeter/jmeter/correlation/gui/templates/ValidationTest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.blazemeter.jmeter.correlation.gui.templates;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import org.junit.Test;
-
-public class ValidationTest {
-
- private Validation validation;
-
- @Test
- public void shouldReturnFalseWhenFailsValidationIsMeet() {
- validation = new Validation(text -> text.isEmpty(), "%s is empty");
- assertThat(validation.failsValidation("")).isTrue();
- }
-
- @Test
- public void shouldReturnFalseWhenFailsValidationNotMeet() {
- validation = new Validation(text -> text.isEmpty(), "%s is empty");
- validation.failsValidation("Not empty text");
- assertThat(validation.failsValidation("Not empty text")).isFalse();
- }
-
- @Test
- public void shouldFormatErrorMessageWhenFailsValidationIsMeet() {
- validation = new Validation(text -> text.isEmpty(), "%s is empty");
- validation.failsValidation("");
- assertThat(validation.formatErrorMessage("ID")).isEqualTo("ID is empty");
- }
-}