diff --git a/test/groovy/UtilsTest.groovy b/test/groovy/UtilsTest.groovy deleted file mode 100644 index 085ccd8c3..000000000 --- a/test/groovy/UtilsTest.groovy +++ /dev/null @@ -1,46 +0,0 @@ -import org.junit.Rule -import org.junit.Before -import org.junit.Test -import org.junit.rules.ExpectedException - -import com.sap.piper.Utils - - -class UtilsTest { - - @Rule - public ExpectedException thrown = new ExpectedException().none() - - private utils = new Utils() - private parameters - - - @Before - void setup() { - - parameters = [:] - } - - @Test - void noValueGetMandatoryParameterTest() { - - thrown.expect(Exception) - thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR test") - - utils.getMandatoryParameter(parameters, 'test', null) - } - - @Test - void defaultValueGetMandatoryParameterTest() { - - assert utils.getMandatoryParameter(parameters, 'test', 'default') == 'default' - } - - @Test - void valueGetmandatoryParameterTest() { - - parameters.put('test', 'value') - - assert utils.getMandatoryParameter(parameters, 'test', null) == 'value' - } -} diff --git a/test/groovy/FileUtilsTest.groovy b/test/groovy/com/sap/piper/FileUtilsTest.groovy similarity index 100% rename from test/groovy/FileUtilsTest.groovy rename to test/groovy/com/sap/piper/FileUtilsTest.groovy diff --git a/test/groovy/com/sap/piper/UtilsTest.groovy b/test/groovy/com/sap/piper/UtilsTest.groovy index 99f9127bb..085ccd8c3 100644 --- a/test/groovy/com/sap/piper/UtilsTest.groovy +++ b/test/groovy/com/sap/piper/UtilsTest.groovy @@ -1,75 +1,46 @@ -package com.sap.piper - -import com.lesfurets.jenkins.unit.BasePipelineTest -import org.junit.Before import org.junit.Rule +import org.junit.Before import org.junit.Test import org.junit.rules.ExpectedException -import org.junit.rules.RuleChain -import util.Rules -import util.SharedLibraryCreator -import static org.hamcrest.Matchers.containsString -import static org.hamcrest.Matchers.hasSize -import static org.junit.Assert.assertEquals -import static org.junit.Assert.assertThat +import com.sap.piper.Utils -class UtilsTest extends BasePipelineTest { + +class UtilsTest { @Rule - public ExpectedException exception = ExpectedException.none() + public ExpectedException thrown = new ExpectedException().none() - @Rule - public RuleChain rules = Rules.getCommonRules(this, SharedLibraryCreator.lazyLoadedLibrary) + private utils = new Utils() + private parameters - Utils utils @Before - void init() throws Exception { - utils = new Utils() - prepareObjectInterceptors(utils) - } + void setup() { - void prepareObjectInterceptors(object) { - object.metaClass.invokeMethod = helper.getMethodInterceptor() - object.metaClass.static.invokeMethod = helper.getMethodInterceptor() - object.metaClass.methodMissing = helper.getMethodMissingInterceptor() + parameters = [:] } @Test - void testGetMandatoryParameterValid() { + void noValueGetMandatoryParameterTest() { - def sourceMap = [test1: 'value1', test2: 'value2'] - - def defaultFallbackMap = [myDefault1: 'default1'] - - assertEquals('value1', utils.getMandatoryParameter(sourceMap, 'test1', null)) - - assertEquals('value1', utils.getMandatoryParameter(sourceMap, 'test1', '')) - - assertEquals('value1', utils.getMandatoryParameter(sourceMap, 'test1', 'customValue')) + thrown.expect(Exception) + thrown.expectMessage("ERROR - NO VALUE AVAILABLE FOR test") + utils.getMandatoryParameter(parameters, 'test', null) } @Test - void testGetMandatoryParameterDefaultFallback() { + void defaultValueGetMandatoryParameterTest() { - def myMap = [test1: 'value1', test2: 'value2'] - - assertEquals('', utils.getMandatoryParameter(myMap, 'test3', '')) - assertEquals('customValue', utils.getMandatoryParameter(myMap, 'test3', 'customValue')) + assert utils.getMandatoryParameter(parameters, 'test', 'default') == 'default' } - @Test - void testGetMandatoryParameterFail() { + void valueGetmandatoryParameterTest() { - def myMap = [test1: 'value1', test2: 'value2'] + parameters.put('test', 'value') - exception.expect(Exception.class) - - exception.expectMessage("ERROR - NO VALUE AVAILABLE FOR") - - utils.getMandatoryParameter(myMap, 'test3', null) + assert utils.getMandatoryParameter(parameters, 'test', null) == 'value' } } diff --git a/test/groovy/VersionTest.groovy b/test/groovy/com/sap/piper/VersionTest.groovy similarity index 100% rename from test/groovy/VersionTest.groovy rename to test/groovy/com/sap/piper/VersionTest.groovy