From 5b22fd176b377a3391e61d1b13a3d11c15651ffe Mon Sep 17 00:00:00 2001 From: Yahav Itzhak Date: Wed, 20 Apr 2022 15:15:56 +0300 Subject: [PATCH] Remove TaskUtilsTest (#180) --- pom.xml | 12 --- .../org/jfrog/bamboo/utils/TaskUtilsTest.java | 87 ------------------- 2 files changed, 99 deletions(-) delete mode 100644 src/test/java/org/jfrog/bamboo/utils/TaskUtilsTest.java diff --git a/pom.xml b/pom.xml index 8ef880b9..82f2221f 100644 --- a/pom.xml +++ b/pom.xml @@ -345,18 +345,6 @@ 4.13.1 test - - org.mockito - mockito-core - 4.4.0 - test - - - org.mockito - mockito-inline - 4.4.0 - test - com.jfrog.testing jfrog-testing-infra diff --git a/src/test/java/org/jfrog/bamboo/utils/TaskUtilsTest.java b/src/test/java/org/jfrog/bamboo/utils/TaskUtilsTest.java deleted file mode 100644 index 1431447a..00000000 --- a/src/test/java/org/jfrog/bamboo/utils/TaskUtilsTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.jfrog.bamboo.utils; - -import com.atlassian.bamboo.task.TaskContext; -import com.atlassian.bamboo.v2.build.BuildContext; -import com.atlassian.bamboo.v2.build.CurrentBuildResult; -import org.jfrog.build.api.Build; -import org.jfrog.build.api.Dependency; -import org.jfrog.build.api.Module; -import org.jfrog.build.api.builder.BuildInfoBuilder; -import org.jfrog.build.api.builder.DependencyBuilder; -import org.jfrog.build.api.builder.ModuleBuilder; -import org.jfrog.build.extractor.BuildInfoExtractorUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; - -import java.io.IOException; -import java.util.*; - -import static org.jfrog.bamboo.util.TaskUtils.addBuildInfoToContext; -import static org.jfrog.bamboo.util.TaskUtils.getAndDeleteAggregatedBuildInfo; -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - -/** - * @author yahavi - **/ -public class TaskUtilsTest { - private Map customBuildData; - private AutoCloseable mocks; - - @Mock - CurrentBuildResult buildResult; - @Mock - BuildContext buildContext; - @Mock - TaskContext taskContext; - - @Before - public void setUp() { - mocks = MockitoAnnotations.openMocks(this); - customBuildData = new HashMap<>(); - when(taskContext.getBuildContext()).thenReturn(buildContext); - when(buildContext.getParentBuildContext()).thenReturn(buildContext); - when(buildContext.getBuildResult()).thenReturn(buildResult); - when(buildResult.getCustomBuildData()).thenReturn(customBuildData); - } - - @After - public void tearDown() throws Exception { - mocks.close(); - } - - @Test - public void TestAddBuildInfoToContextOneDependency() throws IOException { - List dependencyList = new ArrayList<>(); - dependencyList.add(new DependencyBuilder().id("a:b:c").build()); - testAddBuildInfoToContext(dependencyList); - } - - @Test - public void TestAddBuildInfoToContextManyDependencies() throws IOException { - List dependencyList = new ArrayList<>(); - for (int i = 0; i < 100000; i++) { - dependencyList.add(new DependencyBuilder().id(String.valueOf(i)).build()); - } - testAddBuildInfoToContext(dependencyList); - } - - private void testAddBuildInfoToContext(List dependencyList) throws IOException { - // Create a build info with the input dependencies - Module module = new ModuleBuilder().id("test-module").dependencies(dependencyList).build(); - Build build = new BuildInfoBuilder("test-build").number("1").started(new Date().toString()).addModule(module).build(); - String expectedBuildInfo = BuildInfoExtractorUtils.buildInfoToJsonString(build); - - // Run addBuildInfoToContext - addBuildInfoToContext(taskContext, expectedBuildInfo); - - // Run getAndDeleteAggregatedBuildInfo and make sure the actual Build Info equals to the expected - assertEquals(expectedBuildInfo, getAndDeleteAggregatedBuildInfo(taskContext)); - - // Make sure that all buildData variables deleted - assertEquals(new HashMap<>(), customBuildData); - } -}