From cada60912be3a2b39fedbe8dddd91f1408ded710 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=97=E4=BA=AC-=E5=BC=A0=E5=87=A4=E6=9D=B0?= Date: Tue, 26 Mar 2024 16:15:53 +0800 Subject: [PATCH] add specific type to Mockito argument matcher any(),and work for array types --- .../template/context/MockitoMockBuilder.java | 37 ++++++++----------- .../com/example/services/impl/FooTest.java | 2 +- .../com/example/services/impl/FooTest.groovy | 2 +- .../com/example/services/impl/FooTest.java | 2 +- .../com/example/services/impl/FooTest.groovy | 2 +- .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.groovy | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.groovy | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.groovy | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 12 +++--- .../com/example/services/impl/FooTest.groovy | 12 +++--- .../com/example/services/impl/FooTest.java | 12 +++--- .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.groovy | 2 + .../com/example/services/impl/FooTest.java | 2 + .../com/example/services/impl/FooTest.java | 2 + 30 files changed, 82 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/weirddev/testme/intellij/template/context/MockitoMockBuilder.java b/src/main/java/com/weirddev/testme/intellij/template/context/MockitoMockBuilder.java index 4708e107..23f7068d 100644 --- a/src/main/java/com/weirddev/testme/intellij/template/context/MockitoMockBuilder.java +++ b/src/main/java/com/weirddev/testme/intellij/template/context/MockitoMockBuilder.java @@ -227,31 +227,26 @@ public String buildMockArgsMatchers(List params,String language) { */ @NotNull private String deductMatcherTypeMethod(Param param, Language language) { - String matcherType; - if (param.getType().isVarargs()) { - matcherType = "anyVararg"; + Type type = param.getType(); + String matcherMethod = resolveMatcherMethod(type); + if (language == Language.Scala) { + return matcherMethod; } - else { - matcherType = TYPE_TO_ARG_MATCHERS.get(param.getType().getCanonicalName()); - } - if (matcherType == null) { - matcherType = "any"; - } - //todo support anyCollection(),anyMap(),anySet() and consider arrays - if (language != Language.Scala) { - matcherType += "()"; - } - // add specific type to any() - if( matcherType.equals("any()")){ - matcherType = addSpecificType(param.getType().getName()); + else if (!type.isPrimitive() && "any".equals(matcherMethod)) { + return matcherMethod + "("+ type.getCanonicalName()+(type.isArray()? "[]":"") +".class)"; + } else { + return matcherMethod+"()"; } - return matcherType; } - @SuppressWarnings("unused") - @Deprecated - public boolean shouldStub(Method testMethod, List testedClassFields) { - return callsMockMethod(testMethod, testedClassFields, Method::hasReturn, null); + private static String resolveMatcherMethod(Type type) { + if (type.isVarargs()) { + return "anyVararg"; + } else if(!type.isArray() && TYPE_TO_ARG_MATCHERS.containsKey(type.getCanonicalName())){ + return TYPE_TO_ARG_MATCHERS.get(type.getCanonicalName()); + } else { + return "any"; + } } String addSpecificType(String typeName) { diff --git a/testData/testMeGenerator/inheritance/test/com/example/services/impl/FooTest.java b/testData/testMeGenerator/inheritance/test/com/example/services/impl/FooTest.java index 73af8848..f1dab1c2 100644 --- a/testData/testMeGenerator/inheritance/test/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/inheritance/test/com/example/services/impl/FooTest.java @@ -25,7 +25,7 @@ public void setUp() { @Test public void testFight() throws Exception { - when(fooFighter.fight(any(Fire.class))).thenReturn("fightResponse"); + when(fooFighter.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); String result = foo.fight(new com.example.foes.Fire(), "foeName"); Assert.assertEquals("replaceMeWithExpectedResult", result); diff --git a/testData/testMeGenerator/inheritance/testGroovy/com/example/services/impl/FooTest.groovy b/testData/testMeGenerator/inheritance/testGroovy/com/example/services/impl/FooTest.groovy index 95da7602..813b36a8 100644 --- a/testData/testMeGenerator/inheritance/testGroovy/com/example/services/impl/FooTest.groovy +++ b/testData/testMeGenerator/inheritance/testGroovy/com/example/services/impl/FooTest.groovy @@ -23,7 +23,7 @@ class FooTest { @Test void testFight() { - when(fooFighter.fight(any(Fire.class))).thenReturn("fightResponse") + when(fooFighter.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse") java.lang.String result = foo.fight(new com.example.foes.Fire(), "foeName") assert result == "replaceMeWithExpectedResult" diff --git a/testData/testMeGenerator/inheritanceIgnored/test/com/example/services/impl/FooTest.java b/testData/testMeGenerator/inheritanceIgnored/test/com/example/services/impl/FooTest.java index 5d4ae249..042293f1 100644 --- a/testData/testMeGenerator/inheritanceIgnored/test/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/inheritanceIgnored/test/com/example/services/impl/FooTest.java @@ -25,7 +25,7 @@ public void setUp() { @Test public void testFight() throws Exception { - when(fooFighter.fight(any(Fire.class))).thenReturn("fightResponse"); + when(fooFighter.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); String result = foo.fight(new com.example.foes.Fire(), "foeName"); Assert.assertEquals("replaceMeWithExpectedResult", result); diff --git a/testData/testMeGenerator/inheritanceIgnored/testGroovy/com/example/services/impl/FooTest.groovy b/testData/testMeGenerator/inheritanceIgnored/testGroovy/com/example/services/impl/FooTest.groovy index bdc059b8..4e7514ec 100644 --- a/testData/testMeGenerator/inheritanceIgnored/testGroovy/com/example/services/impl/FooTest.groovy +++ b/testData/testMeGenerator/inheritanceIgnored/testGroovy/com/example/services/impl/FooTest.groovy @@ -23,7 +23,7 @@ class FooTest { @Test void testFight() { - when(fooFighter.fight(any(Fire.class))).thenReturn("fightResponse") + when(fooFighter.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse") java.lang.String result = foo.fight(new com.example.foes.Fire(), "foeName") assert result == "replaceMeWithExpectedResult" diff --git a/testData/testMeGenerator/mockFieldsInDependencyInjection/test/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDependencyInjection/test/com/example/services/impl/FooTest.java index 273f9784..8ae91316 100644 --- a/testData/testMeGenerator/mockFieldsInDependencyInjection/test/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDependencyInjection/test/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.Assert; import org.junit.Before; diff --git a/testData/testMeGenerator/mockFieldsInDependencyInjection/testGroovy/com/example/services/impl/FooTest.groovy b/testData/testMeGenerator/mockFieldsInDependencyInjection/testGroovy/com/example/services/impl/FooTest.groovy index 72035cca..fd764ef1 100644 --- a/testData/testMeGenerator/mockFieldsInDependencyInjection/testGroovy/com/example/services/impl/FooTest.groovy +++ b/testData/testMeGenerator/mockFieldsInDependencyInjection/testGroovy/com/example/services/impl/FooTest.groovy @@ -1,7 +1,9 @@ package com.example.services.impl import com.example.beans.ConvertedBean +import com.example.foes.Fear import com.example.foes.Fire +import com.example.foes.Ice import com.example.warriers.TechFighter import org.junit.Test import org.junit.Before diff --git a/testData/testMeGenerator/mockFieldsInDependencyInjection/testJunit5/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDependencyInjection/testJunit5/com/example/services/impl/FooTest.java index fe1ec6e8..d11790a9 100644 --- a/testData/testMeGenerator/mockFieldsInDependencyInjection/testJunit5/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDependencyInjection/testJunit5/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; diff --git a/testData/testMeGenerator/mockFieldsInDependencyInjection/testPowerMock/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDependencyInjection/testPowerMock/com/example/services/impl/FooTest.java index 9d5454f5..4ec047a0 100644 --- a/testData/testMeGenerator/mockFieldsInDependencyInjection/testPowerMock/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDependencyInjection/testPowerMock/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.Assert; import org.junit.Before; diff --git a/testData/testMeGenerator/mockFieldsInDependencyInjection/testTestNg/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDependencyInjection/testTestNg/com/example/services/impl/FooTest.java index d452d686..c3b9f608 100644 --- a/testData/testMeGenerator/mockFieldsInDependencyInjection/testTestNg/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDependencyInjection/testTestNg/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.mockito.InjectMocks; import org.mockito.Mock; diff --git a/testData/testMeGenerator/mockFieldsInDiWithCtor/test/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDiWithCtor/test/com/example/services/impl/FooTest.java index d169e6e6..544c9f83 100644 --- a/testData/testMeGenerator/mockFieldsInDiWithCtor/test/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDiWithCtor/test/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.Assert; import org.junit.Before; diff --git a/testData/testMeGenerator/mockFieldsInDiWithCtor/testGroovy/com/example/services/impl/FooTest.groovy b/testData/testMeGenerator/mockFieldsInDiWithCtor/testGroovy/com/example/services/impl/FooTest.groovy index 1d764a22..5bc48044 100644 --- a/testData/testMeGenerator/mockFieldsInDiWithCtor/testGroovy/com/example/services/impl/FooTest.groovy +++ b/testData/testMeGenerator/mockFieldsInDiWithCtor/testGroovy/com/example/services/impl/FooTest.groovy @@ -1,7 +1,9 @@ package com.example.services.impl import com.example.beans.ConvertedBean +import com.example.foes.Fear import com.example.foes.Fire +import com.example.foes.Ice import com.example.warriers.TechFighter import org.junit.Test import org.junit.Before diff --git a/testData/testMeGenerator/mockFieldsInDiWithCtor/testJunit5/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDiWithCtor/testJunit5/com/example/services/impl/FooTest.java index 3a7788c0..dbbd5c07 100644 --- a/testData/testMeGenerator/mockFieldsInDiWithCtor/testJunit5/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDiWithCtor/testJunit5/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; diff --git a/testData/testMeGenerator/mockFieldsInDiWithCtor/testTestNg/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDiWithCtor/testTestNg/com/example/services/impl/FooTest.java index 84e3fb27..bbee7002 100644 --- a/testData/testMeGenerator/mockFieldsInDiWithCtor/testTestNg/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDiWithCtor/testTestNg/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.mockito.InjectMocks; import org.mockito.Mock; diff --git a/testData/testMeGenerator/mockFieldsInDiWithSetter/test/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDiWithSetter/test/com/example/services/impl/FooTest.java index 273f9784..8ae91316 100644 --- a/testData/testMeGenerator/mockFieldsInDiWithSetter/test/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDiWithSetter/test/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.Assert; import org.junit.Before; diff --git a/testData/testMeGenerator/mockFieldsInDiWithSetter/testGroovy/com/example/services/impl/FooTest.groovy b/testData/testMeGenerator/mockFieldsInDiWithSetter/testGroovy/com/example/services/impl/FooTest.groovy index 72035cca..fd764ef1 100644 --- a/testData/testMeGenerator/mockFieldsInDiWithSetter/testGroovy/com/example/services/impl/FooTest.groovy +++ b/testData/testMeGenerator/mockFieldsInDiWithSetter/testGroovy/com/example/services/impl/FooTest.groovy @@ -1,7 +1,9 @@ package com.example.services.impl import com.example.beans.ConvertedBean +import com.example.foes.Fear import com.example.foes.Fire +import com.example.foes.Ice import com.example.warriers.TechFighter import org.junit.Test import org.junit.Before diff --git a/testData/testMeGenerator/mockFieldsInDiWithSetter/testJunit5/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDiWithSetter/testJunit5/com/example/services/impl/FooTest.java index fe1ec6e8..d11790a9 100644 --- a/testData/testMeGenerator/mockFieldsInDiWithSetter/testJunit5/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDiWithSetter/testJunit5/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; diff --git a/testData/testMeGenerator/mockFieldsInDiWithSetter/testTestNg/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockFieldsInDiWithSetter/testTestNg/com/example/services/impl/FooTest.java index d452d686..c3b9f608 100644 --- a/testData/testMeGenerator/mockFieldsInDiWithSetter/testTestNg/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockFieldsInDiWithSetter/testTestNg/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.mockito.InjectMocks; import org.mockito.Mock; diff --git a/testData/testMeGenerator/mockReturned/test/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockReturned/test/com/example/services/impl/FooTest.java index 58e98b82..f97062e9 100644 --- a/testData/testMeGenerator/mockReturned/test/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockReturned/test/com/example/services/impl/FooTest.java @@ -2,7 +2,9 @@ import com.example.beans.ConvertedBean; import com.example.dependencies.Logger; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.FooFighter; import org.junit.Assert; import org.junit.Before; diff --git a/testData/testMeGenerator/mockReturned/testJunit5/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockReturned/testJunit5/com/example/services/impl/FooTest.java index 63aa281c..8e6e4e0c 100644 --- a/testData/testMeGenerator/mockReturned/testJunit5/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockReturned/testJunit5/com/example/services/impl/FooTest.java @@ -2,7 +2,9 @@ import com.example.beans.ConvertedBean; import com.example.dependencies.Logger; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.FooFighter; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; diff --git a/testData/testMeGenerator/mockReturned/testTestNg/com/example/services/impl/FooTest.java b/testData/testMeGenerator/mockReturned/testTestNg/com/example/services/impl/FooTest.java index 707ae6ce..12eb4552 100644 --- a/testData/testMeGenerator/mockReturned/testTestNg/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/mockReturned/testTestNg/com/example/services/impl/FooTest.java @@ -2,7 +2,9 @@ import com.example.beans.ConvertedBean; import com.example.dependencies.Logger; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.FooFighter; import org.mockito.InjectMocks; import org.mockito.Mock; diff --git a/testData/testMeGenerator/renderInternalMethodCallStubs/testPowerMock/com/example/services/impl/FooTest.java b/testData/testMeGenerator/renderInternalMethodCallStubs/testPowerMock/com/example/services/impl/FooTest.java index 0ff8229b..cee84562 100644 --- a/testData/testMeGenerator/renderInternalMethodCallStubs/testPowerMock/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/renderInternalMethodCallStubs/testPowerMock/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.Assert; import org.junit.Before; diff --git a/testData/testMeGenerator/renderInternalMethodCallStubsIgnored/testPowerMock/com/example/services/impl/FooTest.java b/testData/testMeGenerator/renderInternalMethodCallStubsIgnored/testPowerMock/com/example/services/impl/FooTest.java index 9d5454f5..4ec047a0 100644 --- a/testData/testMeGenerator/renderInternalMethodCallStubsIgnored/testPowerMock/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/renderInternalMethodCallStubsIgnored/testPowerMock/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.Assert; import org.junit.Before; diff --git a/testData/testMeGenerator/variousFieldTypes/test/com/example/services/impl/FooTest.java b/testData/testMeGenerator/variousFieldTypes/test/com/example/services/impl/FooTest.java index 56563c8c..c014c6cf 100644 --- a/testData/testMeGenerator/variousFieldTypes/test/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/variousFieldTypes/test/com/example/services/impl/FooTest.java @@ -45,12 +45,12 @@ public void setUp() { @Test public void testFight() throws Exception { - when(fooFighter.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterProtected.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterDefault.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterPublic.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterFinal.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterStatic.fight(any(Fire.class))).thenReturn("fightResponse"); + when(fooFighter.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterProtected.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterDefault.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterPublic.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterFinal.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterStatic.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); when(innerOfPublicInnerClass.methodOfInnerClass()).thenReturn(new Foo().new PublicInnerClass().new InnerOfPublicInnerClass()); String result = foo.fight(new com.example.foes.Fire(), "foeName"); diff --git a/testData/testMeGenerator/variousFieldTypes/testGroovy/com/example/services/impl/FooTest.groovy b/testData/testMeGenerator/variousFieldTypes/testGroovy/com/example/services/impl/FooTest.groovy index 5f9d523c..ab2d2e50 100644 --- a/testData/testMeGenerator/variousFieldTypes/testGroovy/com/example/services/impl/FooTest.groovy +++ b/testData/testMeGenerator/variousFieldTypes/testGroovy/com/example/services/impl/FooTest.groovy @@ -41,12 +41,12 @@ class FooTest { @Test void testFight() { - when(fooFighter.fight(any(Fire.class))).thenReturn("fightResponse") - when(fooFighterProtected.fight(any(Fire.class))).thenReturn("fightResponse") - when(fooFighterDefault.fight(any(Fire.class))).thenReturn("fightResponse") - when(fooFighterPublic.fight(any(Fire.class))).thenReturn("fightResponse") - when(fooFighterFinal.fight(any(Fire.class))).thenReturn("fightResponse") - when(fooFighterStatic.fight(any(Fire.class))).thenReturn("fightResponse") + when(fooFighter.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse") + when(fooFighterProtected.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse") + when(fooFighterDefault.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse") + when(fooFighterPublic.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse") + when(fooFighterFinal.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse") + when(fooFighterStatic.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse") when(innerOfPublicInnerClass.methodOfInnerClass()).thenReturn(new com.example.services.impl.Foo.PublicInnerClass.InnerOfPublicInnerClass(new com.example.services.impl.Foo.PublicInnerClass(new com.example.services.impl.Foo()))) java.lang.String result = foo.fight(new com.example.foes.Fire(), "foeName") diff --git a/testData/testMeGenerator/variousFieldTypes/testPowerMock/com/example/services/impl/FooTest.java b/testData/testMeGenerator/variousFieldTypes/testPowerMock/com/example/services/impl/FooTest.java index 37d7dfd5..d568d92f 100644 --- a/testData/testMeGenerator/variousFieldTypes/testPowerMock/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/variousFieldTypes/testPowerMock/com/example/services/impl/FooTest.java @@ -57,12 +57,12 @@ public void setUp() { @Test public void testFight() throws Exception { - when(fooFighter.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterProtected.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterDefault.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterPublic.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterFinal.fight(any(Fire.class))).thenReturn("fightResponse"); - when(fooFighterStatic.fight(any(Fire.class))).thenReturn("fightResponse"); + when(fooFighter.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterProtected.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterDefault.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterPublic.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterFinal.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); + when(fooFighterStatic.fight(any(com.example.foes.Fire.class))).thenReturn("fightResponse"); when(innerOfPublicInnerClass.methodOfInnerClass()).thenReturn(new Foo().new PublicInnerClass().new InnerOfPublicInnerClass()); String result = foo.fight(new com.example.foes.Fire(), "foeName"); verify(publicInnerClass).methodOfInnerClass(); diff --git a/testData/testMeGenerator/verifyMethodCall/test/com/example/services/impl/FooTest.java b/testData/testMeGenerator/verifyMethodCall/test/com/example/services/impl/FooTest.java index d169e6e6..544c9f83 100644 --- a/testData/testMeGenerator/verifyMethodCall/test/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/verifyMethodCall/test/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.Assert; import org.junit.Before; diff --git a/testData/testMeGenerator/verifyMethodCall/testGroovy/com/example/services/impl/FooTest.groovy b/testData/testMeGenerator/verifyMethodCall/testGroovy/com/example/services/impl/FooTest.groovy index 1d764a22..5bc48044 100644 --- a/testData/testMeGenerator/verifyMethodCall/testGroovy/com/example/services/impl/FooTest.groovy +++ b/testData/testMeGenerator/verifyMethodCall/testGroovy/com/example/services/impl/FooTest.groovy @@ -1,7 +1,9 @@ package com.example.services.impl import com.example.beans.ConvertedBean +import com.example.foes.Fear import com.example.foes.Fire +import com.example.foes.Ice import com.example.warriers.TechFighter import org.junit.Test import org.junit.Before diff --git a/testData/testMeGenerator/verifyMethodCall/testJunit5/com/example/services/impl/FooTest.java b/testData/testMeGenerator/verifyMethodCall/testJunit5/com/example/services/impl/FooTest.java index 3a7788c0..dbbd5c07 100644 --- a/testData/testMeGenerator/verifyMethodCall/testJunit5/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/verifyMethodCall/testJunit5/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; diff --git a/testData/testMeGenerator/verifyMethodCall/testTestNg/com/example/services/impl/FooTest.java b/testData/testMeGenerator/verifyMethodCall/testTestNg/com/example/services/impl/FooTest.java index 84e3fb27..bbee7002 100644 --- a/testData/testMeGenerator/verifyMethodCall/testTestNg/com/example/services/impl/FooTest.java +++ b/testData/testMeGenerator/verifyMethodCall/testTestNg/com/example/services/impl/FooTest.java @@ -1,7 +1,9 @@ package com.example.services.impl; import com.example.beans.ConvertedBean; +import com.example.foes.Fear; import com.example.foes.Fire; +import com.example.foes.Ice; import com.example.warriers.TechFighter; import org.mockito.InjectMocks; import org.mockito.Mock;