/*
 * This file was automatically generated by EvoSuite
 * Tue Dec 10 19:56:41 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.InvokerListener;
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.listener.ListenerInvokerWrapper;
import com.alibaba.dubbo.rpc.protocol.InvokerWrapper;
import java.lang.reflect.Array;
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  {
      URL uRL0 = new URL("The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", 2185, "The current consumer in the service blacklist. consumer: ");
      Integer integer0 = new Integer(2185);
      URL uRL1 = uRL0.addParameter("rule", (Number) integer0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<ConditionRouter>> linkedList0 = new LinkedList<Invoker<ConditionRouter>>();
      InvokerWrapper<ConditionRouter> invokerWrapper0 = new InvokerWrapper<ConditionRouter>((Invoker<ConditionRouter>) null, uRL1);
      LinkedList<InvokerListener> linkedList1 = new LinkedList<InvokerListener>();
      ListenerInvokerWrapper<ConditionRouter> listenerInvokerWrapper0 = new ListenerInvokerWrapper<ConditionRouter>(invokerWrapper0, linkedList1);
      linkedList0.add((Invoker<ConditionRouter>) listenerInvokerWrapper0);
      List<Invoker<ConditionRouter>> list0 = conditionRouter0.route((List<Invoker<ConditionRouter>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertEquals(1, list0.size());
  }

  @Test(timeout = 4000)
  public void test01()  throws Throwable  {
      URL uRL0 = new URL("The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", 2185, "The current consumer in the service blacklist. consumer: ");
      Integer integer0 = new Integer(2185);
      URL uRL1 = uRL0.addParameter("rule", (Number) integer0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<ConditionRouter>> linkedList0 = new LinkedList<Invoker<ConditionRouter>>();
      linkedList0.add((Invoker<ConditionRouter>) null);
      List<Invoker<ConditionRouter>> list0 = conditionRouter0.route((List<Invoker<ConditionRouter>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertFalse(list0.isEmpty());
  }

  @Test(timeout = 4000)
  public void test02()  throws Throwable  {
      URL uRL0 = new URL("The current consumer Rn the service blacklist. consumer: ", "The current consumer Rn the service blacklist. consumer: ", 2185, "The current consumer Rn the service blacklist. consumer: ");
      Integer integer0 = new Integer(2185);
      URL uRL1 = uRL0.addParameter("rule", (Number) integer0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = conditionRouter0.getUrl();
      assertEquals("The current consumer Rn the service blacklist. consumer: ", uRL2.getProtocol());
  }

  @Test(timeout = 4000)
  public void test03()  throws Throwable  {
      String[] stringArray0 = new String[6];
      stringArray0[0] = "N:2N";
      stringArray0[2] = "rule";
      stringArray0[4] = "rule";
      stringArray0[5] = "rule";
      URL uRL0 = new URL("rule", "rule", (-4784), "N:2N", stringArray0);
      Map<String, String> map0 = uRL0.toMap();
      URL uRL1 = new URL("rule", "N:2N", (-4784), "rule", map0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      ConditionRouter conditionRouter1 = new ConditionRouter(uRL0);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter1);
      assertEquals((-36), int0);
  }

  @Test(timeout = 4000)
  public void test04()  throws Throwable  {
      String[] stringArray0 = new String[6];
      stringArray0[4] = "rule";
      stringArray0[5] = "rule";
      URL uRL0 = new URL("rule", "rule", (-4784), "N:2N", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      // Undeclared exception!
      try { 
        conditionRouter0.compareTo((Router) conditionRouter0);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
         verifyException("java.util.TreeMap", e);
      }
  }

  @Test(timeout = 4000)
  public void test05()  throws Throwable  {
      URL uRL0 = new URL("R=/5x", "rule", 900000, "rule", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameter("priority", false);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: NumberFormatException");
      
      } catch(NumberFormatException e) {
         //
         // For input string: \"false\"
         //
         verifyException("java.lang.NumberFormatException", e);
      }
  }

  @Test(timeout = 4000)
  public void test06()  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 test07()  throws Throwable  {
      URL uRL0 = new URL("Ie%Ge0eh+O%,fCw_i'g", "Ie%Ge0eh+O%,fCw_i'g", (-2499));
      URL uRL1 = uRL0.addParameterIfAbsent("rule", "Ie%Ge0eh+O%,fCw_i'g");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalArgumentException");
      
      } catch(IllegalArgumentException e) {
         //
         // URLDecoder: Illegal hex characters in escape (%) pattern - For input string: \"Ge\"
         //
         verifyException("java.net.URLDecoder", e);
      }
  }

  @Test(timeout = 4000)
  public void test08()  throws Throwable  {
      URL uRL0 = new URL("R+=>", "R+=>", "R+=>", "R+=>", (-2482), "R+=>");
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "R+=>");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      Class<Object>[] classArray0 = (Class<Object>[]) Array.newInstance(Class.class, 0);
      RpcInvocation rpcInvocation0 = new RpcInvocation("R+=>", classArray0, classArray0);
      boolean boolean0 = conditionRouter0.matchWhen(uRL1, rpcInvocation0);
      assertTrue(boolean0);
  }

  @Test(timeout = 4000)
  public void test09()  throws Throwable  {
      URL uRL0 = new URL("The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", 2185, "The current consumer in the service blacklist. consumer: ");
      Integer integer0 = new Integer(2185);
      URL uRL1 = uRL0.addParameter("rule", (Number) integer0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      MockInvokersSelector mockInvokersSelector0 = new MockInvokersSelector();
      int int0 = conditionRouter0.compareTo((Router) mockInvokersSelector0);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test10()  throws Throwable  {
      URL uRL0 = new URL("The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", 2185, "The current consumer in the service blacklist. consumer: ");
      Integer integer0 = new Integer(2185);
      URL uRL1 = uRL0.addParameter("rule", (Number) integer0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) null);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test11()  throws Throwable  {
      URL uRL0 = new URL("The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", 2185, "The current consumer in the service blacklist. consumer: ");
      Integer integer0 = new Integer(2185);
      URL uRL1 = uRL0.addParameter("rule", (Number) integer0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<ConditionRouter>> linkedList0 = new LinkedList<Invoker<ConditionRouter>>();
      List<Invoker<ConditionRouter>> list0 = conditionRouter0.route((List<Invoker<ConditionRouter>>) linkedList0, uRL1, (Invocation) rpcInvocation0);
      assertEquals(0, list0.size());
  }

  @Test(timeout = 4000)
  public void test12()  throws Throwable  {
      URL uRL0 = new URL("Ie%Ge0eh+O%,fCw_i'g", "Ie%Ge0eh+O%,fCw_i'g", "Ie%Ge0eh+O%,fCw_i'g", "Ie%Ge0eh+O%,fCw_i'g", (-2499), "Ie%Ge0eh+O%,fCw_i'g");
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "Ie%Ge0eh+O%,fCw_i'g");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"Ie%Ge0eh+O%,fCw_i'g\", The error char ',' at index 11 before \"fCw_i'g\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test13()  throws Throwable  {
      URL uRL0 = URL.valueOf("rule");
      URL uRL1 = uRL0.addParameter("rule", "<~ ^W)=S7'W");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter0);
      assertEquals(0, int0);
  }

  @Test(timeout = 4000)
  public void test14()  throws Throwable  {
      URL uRL0 = new URL("h5%Ge0e!+O%,fCw_i'g", "h5%Ge0e!+O%,fCw_i'g", "h5%Ge0e!+O%,fCw_i'g", "h5%Ge0e!+O%,fCw_i'g", (-2499), "h5%Ge0e!+O%,fCw_i'g");
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "h5%Ge0e!+O%,fCw_i'g");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"h5%Ge0e!+O%,fCw_i'g\", The error char '!' at index 7 before \"+O%\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test15()  throws Throwable  {
      URL uRL0 = URL.valueOf("rule");
      URL uRL1 = uRL0.addParameter("rule", "[`MGOna[n&iQb");
      URL uRL2 = uRL1.setServiceInterface("rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
  }

  @Test(timeout = 4000)
  public void test16()  throws Throwable  {
      URL uRL0 = new URL("=Pz>", "=Pz>", "=Pz>", "=Pz>", (-2499), "=Pz>");
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "=Pz>");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"=Pz>\", The error char '=' at index 0 before \"Pz>\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test17()  throws Throwable  {
      String[] stringArray0 = new String[6];
      stringArray0[2] = "rule";
      stringArray0[3] = "false";
      URL uRL0 = new URL("I%Ge0eh,O%,fCw_ixg", "false", "rule", "I%Ge0eh,O%,fCw_ixg", (-585), "~'y]$", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
  }

  @Test(timeout = 4000)
  public void test18()  throws Throwable  {
      URL uRL0 = new URL("The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", "The current consumer in the service blacklist. consumer: ", 2185, "The current consumer in the service blacklist. consumer: ");
      Integer integer0 = new Integer(2185);
      URL uRL1 = uRL0.addParameter("rule", (Number) integer0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      List<Invoker<Object>> list0 = conditionRouter0.route((List<Invoker<Object>>) null, uRL1, (Invocation) rpcInvocation0);
      assertNull(list0);
  }

  @Test(timeout = 4000)
  public void test19()  throws Throwable  {
      String[] stringArray0 = new String[8];
      URL uRL0 = new URL("=]8_Ci;e`8puH5x", "=]8_Ci;e`8puH5x", 1386, stringArray0);
      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 test20()  throws Throwable  {
      URL uRL0 = new URL("R+=>", "R+=>", "R+=>", "R+=>", (-2482), "R+=>");
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "R+=>");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = conditionRouter0.getUrl();
      assertEquals("R+=>", uRL2.getProtocol());
  }
}
