Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix self assignment #3301

Merged
merged 3 commits into from
Jan 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,11 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class GenericServiceTest {

Expand Down Expand Up @@ -108,20 +107,20 @@ public void testGenericComplexCompute4FullServiceMetadata() {

FullServiceDefinition fullServiceDefinition = ServiceDefinitionBuilder.buildFullDefinition(DemoService.class);
MethodDefinition methodDefinition = getMethod("complexCompute", fullServiceDefinition.getMethods());
Map parm2= createComplextObject(fullServiceDefinition,var1, var2, l, var3, var4, testEnum);
ComplexObject complexObject = map2bean(parm2);
Map mapObject = createComplexObject(fullServiceDefinition,var1, var2, l, var3, var4, testEnum);
ComplexObject complexObject = map2bean(mapObject);

Invoker<GenericService> invoker = protocol.refer(GenericService.class, url);


GenericService client = proxyFactory.getProxy(invoker, true);
Object result = client.$invoke(methodDefinition.getName(), methodDefinition.getParameterTypes(), new Object[]{"haha", parm2});
Object result = client.$invoke(methodDefinition.getName(), methodDefinition.getParameterTypes(), new Object[]{"haha", mapObject});
Assertions.assertEquals("haha###" + complexObject.toString(), result);


Invoker<DemoService> invoker2 = protocol.refer(DemoService.class, url);
GenericService client2 = (GenericService) proxyFactory.getProxy(invoker2, true);
Object result2 = client2.$invoke("complexCompute", methodDefinition.getParameterTypes(), new Object[]{"haha2", parm2});
Object result2 = client2.$invoke("complexCompute", methodDefinition.getParameterTypes(), new Object[]{"haha2", mapObject});
Assertions.assertEquals("haha2###" + complexObject.toString(), result2);

invoker.destroy();
Expand Down Expand Up @@ -167,7 +166,7 @@ MethodDefinition getMethod(String methodName, List<MethodDefinition> list) {
return null;
}

Map<String, Object> createComplextObject(FullServiceDefinition fullServiceDefinition, String var1, int var2, long l, String[] var3, List<Integer> var4, ComplexObject.TestEnum testEnum) {
Map<String, Object> createComplexObject(FullServiceDefinition fullServiceDefinition, String var1, int var2, long l, String[] var3, List<Integer> var4, ComplexObject.TestEnum testEnum) {
List<TypeDefinition> typeDefinitions = fullServiceDefinition.getTypes();
TypeDefinition topTypeDefinition = null;
TypeDefinition innerTypeDefinition = null;
Expand All @@ -191,7 +190,7 @@ Map<String, Object> createComplextObject(FullServiceDefinition fullServiceDefini
Assertions.assertEquals(topTypeDefinition.getProperties().get("strArrays").getType(), "java.lang.String[]");
Assertions.assertEquals(topTypeDefinition.getProperties().get("innerObject3").getType(), "org.apache.dubbo.service.ComplexObject.InnerObject3[]");
Assertions.assertEquals(topTypeDefinition.getProperties().get("testEnum").getType(), "org.apache.dubbo.service.ComplexObject.TestEnum");
Assertions.assertEquals(topTypeDefinition.getProperties().get("innerObject2").getType(), "java.util.Set<org.apache.dubbo.service.ComplexObject$InnerObject2>");
Assertions.assertEquals(topTypeDefinition.getProperties().get("innerObject2").getType(), "java.util.List<org.apache.dubbo.service.ComplexObject$InnerObject2>");

Assertions.assertSame(innerTypeDefinition.getProperties().get("innerA").getType(), "java.lang.String");
Assertions.assertSame(innerTypeDefinition.getProperties().get("innerB").getType(), "int");
Expand All @@ -216,16 +215,16 @@ Map<String, Object> createComplextObject(FullServiceDefinition fullServiceDefini
innerObjectMap.put("innerA", var1);
innerObjectMap.put("innerB", var2);

Set<Map> innerObject2Set = new HashSet<>(4);
result.put("innerObject2", innerObject2Set);
List<Map> innerObject2List = new ArrayList<>();
result.put("innerObject2", innerObject2List);
Map innerObject2Tmp1 = new HashMap<>(4);
innerObject2Tmp1.put("innerA2", var1 + "_21");
innerObject2Tmp1.put("innerB2", var2 + 100000);
Map innerObject2Tmp2 = new HashMap<>(4);
innerObject2Tmp2.put("innerA2", var1 + "_22");
innerObject2Tmp2.put("innerB2", var2 + 200000);
innerObject2Set.add(innerObject2Tmp1);
innerObject2Set.add(innerObject2Tmp2);
innerObject2List.add(innerObject2Tmp1);
innerObject2List.add(innerObject2Tmp2);

Map innerObject3Tmp1 = new HashMap<>(4);
innerObject3Tmp1.put("innerA3", var1 + "_31");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
*/
package org.apache.dubbo.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
* ON 2018/11/5
Expand All @@ -46,7 +45,7 @@ public ComplexObject(String var1, int var2, long l, String[] var3, List<Integer>
InnerObject2 io22 = new InnerObject2();
io22.setInnerA2(var1 + "_22");
io22.setInnerB2(var2 + 200000);
this.setInnerObject2(new HashSet<InnerObject2>(Arrays.asList(io21, io22)));
this.setInnerObject2(new ArrayList<>(Arrays.asList(io21, io22)));

InnerObject3 io31 = new InnerObject3();
io31.setInnerA3(var1 + "_31");
Expand All @@ -61,7 +60,7 @@ public ComplexObject(String var1, int var2, long l, String[] var3, List<Integer>
}

private InnerObject innerObject;
private Set<InnerObject2> innerObject2;
private List<InnerObject2> innerObject2;
private InnerObject3[] innerObject3;
private String[] strArrays;
private List<Integer> intList;
Expand Down Expand Up @@ -109,11 +108,11 @@ public void setTestEnum(TestEnum testEnum) {
this.testEnum = testEnum;
}

public Set<InnerObject2> getInnerObject2() {
public List<InnerObject2> getInnerObject2() {
return innerObject2;
}

public void setInnerObject2(Set<InnerObject2> innerObject2) {
public void setInnerObject2(List<InnerObject2> innerObject2) {
this.innerObject2 = innerObject2;
}

Expand Down Expand Up @@ -225,15 +224,15 @@ public String getInnerA2() {
return innerA2;
}

public void setInnerA2(String innerA) {
public void setInnerA2(String innerA2) {
this.innerA2 = innerA2;
}

public int getInnerB2() {
return innerB2;
}

public void setInnerB2(int innerB) {
public void setInnerB2(int innerB2) {
this.innerB2 = innerB2;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ public String getInnerA2() {
return innerA2;
}

public void setInnerA2(String innerA) {
public void setInnerA2(String innerA2) {
this.innerA2 = innerA2;
}

public int getInnerB2() {
return innerB2;
}

public void setInnerB2(int innerB) {
public void setInnerB2(int innerB2) {
this.innerB2 = innerB2;
}

Expand Down