/*
 * This file was automatically generated by EvoSuite
 * Tue Dec 10 19:52:53 GMT 2019
 */

package com.alibaba.dubbo.rpc.cluster.router.condition;

import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.runtime.EvoAssertions.*;
import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.rpc.Invocation;
import com.alibaba.dubbo.rpc.Invoker;
import com.alibaba.dubbo.rpc.RpcInvocation;
import com.alibaba.dubbo.rpc.cluster.Router;
import com.alibaba.dubbo.rpc.cluster.router.MockInvokersSelector;
import com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter;
import com.alibaba.dubbo.rpc.protocol.InvokerWrapper;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;

@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true, useJEE = true) 
public class ConditionRouter_ESTest extends ConditionRouter_ESTest_scaffolding {

  @Test(timeout = 4000)
  public void test00()  throws Throwable  {
      String[] stringArray0 = new String[10];
      stringArray0[2] = "rule";
      stringArray0[3] = "rule";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      URL uRL1 = uRL0.addParameter("rule", 1089);
      LinkedList<Invoker<String>> linkedList0 = new LinkedList<Invoker<String>>();
      InvokerWrapper<String> invokerWrapper0 = new InvokerWrapper<String>((Invoker<String>) null, uRL1);
      linkedList0.add((Invoker<String>) invokerWrapper0);
      List<Invoker<String>> list0 = conditionRouter0.route((List<Invoker<String>>) linkedList0, uRL1, (Invocation) rpcInvocation0);
      assertEquals(1, list0.size());
  }

  @Test(timeout = 4000)
  public void test01()  throws Throwable  {
      String[] stringArray0 = new String[10];
      stringArray0[2] = "rule";
      stringArray0[3] = "rule";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      URL uRL1 = uRL0.setHost("rule");
      LinkedList<Invoker<String>> linkedList0 = new LinkedList<Invoker<String>>();
      InvokerWrapper<String> invokerWrapper0 = new InvokerWrapper<String>((Invoker<String>) null, uRL1);
      linkedList0.add((Invoker<String>) invokerWrapper0);
      List<Invoker<String>> list0 = conditionRouter0.route((List<Invoker<String>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertFalse(list0.isEmpty());
  }

  @Test(timeout = 4000)
  public void test02()  throws Throwable  {
      HashMap<String, String> hashMap0 = new HashMap<String, String>();
      URL uRL0 = new URL("&{/,XhH0", "7F]9T%O", 1070, "a(g14N'S", hashMap0);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "YtN@iXCPm");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      ConditionRouter conditionRouter1 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter1);
      assertEquals(0, int0);
  }

  @Test(timeout = 4000)
  public void test03()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[6] = "rule";
      stringArray0[7] = "OyE1$+x=mKf1s?k2u";
      URL uRL0 = new URL("OyE1$+x=mKf1s?k2u", "OyE1$+x=mKf1s?k2u", "d~W%L [O96oezm`8v*", "rule", 1089, "OyE1$+x=mKf1s?k2u", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      ConditionRouter conditionRouter1 = new ConditionRouter(uRL0);
      // Undeclared exception!
      try { 
        conditionRouter0.compareTo((Router) conditionRouter1);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
      }
  }

  @Test(timeout = 4000)
  public void test04()  throws Throwable  {
      String[] stringArray0 = new String[10];
      stringArray0[2] = "rule";
      stringArray0[3] = "rule";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      boolean boolean0 = conditionRouter0.matchWhen(uRL0, rpcInvocation0);
      assertTrue(boolean0);
  }

  @Test(timeout = 4000)
  public void test05()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[6] = "rule";
      stringArray0[7] = "OyE1$+xtmKf1s?k2u";
      URL uRL0 = new URL((String) null, "rule", "YtN@iXCPm", "rule", (-119), "OyE1$+xtmKf1s?k2u", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      URL uRL1 = conditionRouter0.getUrl();
      assertNull(uRL1.getProtocol());
  }

  @Test(timeout = 4000)
  public void test06()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[2] = "rule";
      stringArray0[3] = "a(g14N'S";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<String>> linkedList0 = new LinkedList<Invoker<String>>();
      linkedList0.add((Invoker<String>) null);
      // Undeclared exception!
      try { 
        conditionRouter0.route((List<Invoker<String>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
      }
  }

  @Test(timeout = 4000)
  public void test07()  throws Throwable  {
      URL uRL0 = URL.valueOf("%=Z3[RtLTbej N,A");
      URL uRL1 = uRL0.addParameterAndEncoded("priority", "priority");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: NumberFormatException");
      
      } catch(NumberFormatException e) {
         //
         // For input string: \"priority\"
         //
         verifyException("java.lang.NumberFormatException", e);
      }
  }

  @Test(timeout = 4000)
  public void test08()  throws Throwable  {
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter((URL) null);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test09()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[6] = "rule";
      stringArray0[7] = "}2KaW)%2";
      URL uRL0 = new URL((String) null, "rule", "YtN@iXCPm", "rule", 1089, "}2KaW)%2", stringArray0);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL0);
        fail("Expecting exception: IllegalArgumentException");
      
      } catch(IllegalArgumentException e) {
         //
         // URLDecoder: Incomplete trailing escape (%) pattern
         //
         verifyException("java.net.URLDecoder", e);
      }
  }

  @Test(timeout = 4000)
  public void test10()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[2] = "rule";
      stringArray0[3] = ",";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<String>> linkedList0 = new LinkedList<Invoker<String>>();
      InvokerWrapper<String> invokerWrapper0 = new InvokerWrapper<String>((Invoker<String>) null, uRL0);
      linkedList0.add((Invoker<String>) invokerWrapper0);
      List<Invoker<String>> list0 = conditionRouter0.route((List<Invoker<String>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertEquals(1, list0.size());
  }

  @Test(timeout = 4000)
  public void test11()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[6] = "rule";
      stringArray0[7] = "OyE1$+xtmKf1s?k2u";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, "OyE1$+xtmKf1s?k2u", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      MockInvokersSelector mockInvokersSelector0 = new MockInvokersSelector();
      int int0 = conditionRouter0.compareTo((Router) mockInvokersSelector0);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test12()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[6] = "rule";
      stringArray0[7] = "OyE1$+xtmKf1s?k2u";
      URL uRL0 = new URL((String) null, "rule", "YtN@iXCPm", "rule", 1089, "OyE1$+xtmKf1s?k2u", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      int int0 = conditionRouter0.compareTo((Router) null);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test13()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[2] = "rule";
      stringArray0[3] = "a(g14N'S";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1103, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<String>> linkedList0 = new LinkedList<Invoker<String>>();
      InvokerWrapper<String> invokerWrapper0 = new InvokerWrapper<String>((Invoker<String>) null, uRL0);
      linkedList0.add((Invoker<String>) invokerWrapper0);
      List<Invoker<String>> list0 = conditionRouter0.route((List<Invoker<String>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertFalse(list0.isEmpty());
  }

  @Test(timeout = 4000)
  public void test14()  throws Throwable  {
      String[] stringArray0 = new String[10];
      stringArray0[2] = "rule";
      stringArray0[3] = "rule";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<String>> linkedList0 = new LinkedList<Invoker<String>>();
      List<Invoker<String>> list0 = conditionRouter0.route((List<Invoker<String>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertEquals(0, list0.size());
  }

  @Test(timeout = 4000)
  public void test15()  throws Throwable  {
      String[] stringArray0 = new String[10];
      stringArray0[2] = "rule";
      stringArray0[3] = "rule";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      List<Invoker<Object>> list0 = conditionRouter0.route((List<Invoker<Object>>) null, uRL0, (Invocation) rpcInvocation0);
      assertNull(list0);
  }

  @Test(timeout = 4000)
  public void test16()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[2] = "rule";
      stringArray0[3] = "=x";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL0);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"=x\", The error char '=' at index 0 before \"x\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test17()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[6] = "rule";
      stringArray0[7] = "4&{/,X@h0";
      URL uRL0 = new URL((String) null, "rule", "YKN@iXVPm", "rule", 1089, "4&{/,X@h0", stringArray0);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL0);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"4&{/,X@h0\", The error char ',' at index 4 before \"X@h0\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test18()  throws Throwable  {
      String[] stringArray0 = new String[8];
      stringArray0[6] = "rule";
      stringArray0[7] = "QR!j|C?Z";
      URL uRL0 = new URL((String) null, "rule", "YtE@iXCPm", "rule", 1089, "QR!j|C?Z", stringArray0);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL0);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"QR!j|C?Z\", The error char '!' at index 2 before \"j|C?Z\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test19()  throws Throwable  {
      URL uRL0 = new URL("com.alibaba.dubbo.common.utils.NetUtils", "com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", 1080, (Map<String, String>) null);
      URL uRL1 = uRL0.addParameter("rule", false);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

  @Test(timeout = 4000)
  public void test20()  throws Throwable  {
      URL uRL0 = new URL("com.alibaba.dubbo.common.utils.NetUtils", "com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", 1080, (Map<String, String>) null);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL0);
        fail("Expecting exception: IllegalArgumentException");
      
      } catch(IllegalArgumentException e) {
         //
         // Illegal route rule!
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test21()  throws Throwable  {
      String[] stringArray0 = new String[10];
      stringArray0[2] = "rule";
      stringArray0[3] = "rule";
      URL uRL0 = new URL((String) null, "rule", (String) null, "rule", 1089, (String) null, stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      URL uRL1 = conditionRouter0.getUrl();
      assertEquals("rule", uRL1.getUsername());
  }
}
