/*
 * This file was automatically generated by EvoSuite
 * Tue Dec 10 20:00:27 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.util.HashMap;
import java.util.LinkedList;
import java.util.List;
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[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "kR\"V>4MhQM$n";
      URL uRL0 = new URL("kR\"V>4MhQM$n", "", (-2298), "kR\"V>4MhQM$n", stringArray0);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      LinkedList<Invoker<MockInvokersSelector>> linkedList0 = new LinkedList<Invoker<MockInvokersSelector>>();
      InvokerWrapper<MockInvokersSelector> invokerWrapper0 = new InvokerWrapper<MockInvokersSelector>((Invoker<MockInvokersSelector>) null, uRL0);
      LinkedList<InvokerListener> linkedList1 = new LinkedList<InvokerListener>();
      ListenerInvokerWrapper<MockInvokersSelector> listenerInvokerWrapper0 = new ListenerInvokerWrapper<MockInvokersSelector>(invokerWrapper0, linkedList1);
      linkedList0.add((Invoker<MockInvokersSelector>) listenerInvokerWrapper0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      List<Invoker<MockInvokersSelector>> list0 = conditionRouter0.route((List<Invoker<MockInvokersSelector>>) linkedList0, uRL1, (Invocation) rpcInvocation0);
      assertFalse(list0.isEmpty());
  }

  @Test(timeout = 4000)
  public void test01()  throws Throwable  {
      String[] stringArray0 = new String[4];
      URL uRL0 = new URL("kR\"V>4MhQM$n", "", (-2298), "kR\"V>4MhQM$n", stringArray0);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      LinkedList<Invoker<MockInvokersSelector>> linkedList0 = new LinkedList<Invoker<MockInvokersSelector>>();
      InvokerWrapper<MockInvokersSelector> invokerWrapper0 = new InvokerWrapper<MockInvokersSelector>((Invoker<MockInvokersSelector>) null, uRL0);
      LinkedList<InvokerListener> linkedList1 = new LinkedList<InvokerListener>();
      ListenerInvokerWrapper<MockInvokersSelector> listenerInvokerWrapper0 = new ListenerInvokerWrapper<MockInvokersSelector>(invokerWrapper0, linkedList1);
      linkedList0.add((Invoker<MockInvokersSelector>) listenerInvokerWrapper0);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      List<Invoker<MockInvokersSelector>> list0 = conditionRouter0.route((List<Invoker<MockInvokersSelector>>) linkedList0, uRL1, (Invocation) rpcInvocation0);
      assertEquals(1, list0.size());
  }

  @Test(timeout = 4000)
  public void test02()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "kR\"V>4MhQM$n";
      URL uRL0 = new URL("kR\"V>4MhQM$n", "The route result is empty and foce execute. consumer: ", 3615, "kR\"V>4MhQM$n", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      URL uRL1 = conditionRouter0.getUrl();
      assertNull(uRL1.getUsername());
  }

  @Test(timeout = 4000)
  public void test03()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "kR\"V>4MhQM$n";
      stringArray0[2] = "The route result is empty and force execute. consumer: ";
      URL uRL0 = new URL("kR\"V>4MhQM$n", "The route result is empty and force execute. consumer: ", (-2298), "kR\"V>4MhQM$n", stringArray0);
      URL uRL1 = uRL0.addParameter("1ptg4f/[gt-;c", (CharSequence) "kR\"V>4MhQM$n");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      ConditionRouter conditionRouter1 = new ConditionRouter(uRL0);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter1);
      assertEquals((-35), int0);
  }

  @Test(timeout = 4000)
  public void test04()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "kR\"V>4MhQM$n";
      URL uRL0 = new URL("kR\"V>4MhQM$n", "", (-2298), "kR\"V>4MhQM$n", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      LinkedList<Invoker<MockInvokersSelector>> linkedList0 = new LinkedList<Invoker<MockInvokersSelector>>();
      linkedList0.add((Invoker<MockInvokersSelector>) null);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      // Undeclared exception!
      try { 
        conditionRouter0.route((List<Invoker<MockInvokersSelector>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
        fail("Expecting exception: NullPointerException");
      
      } catch(NullPointerException e) {
         //
         // no message in exception (getMessage() returned null)
         //
      }
  }

  @Test(timeout = 4000)
  public void test05()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "kR\"V>4MhQM$n";
      URL uRL0 = new URL("kR\"V>4MhQM$n", "", (-2298), "kR\"V>4MhQM$n", 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)
         //
      }
  }

  @Test(timeout = 4000)
  public void test06()  throws Throwable  {
      String[] stringArray0 = new String[2];
      stringArray0[0] = "priority";
      stringArray0[1] = "priority";
      URL uRL0 = new URL("priority", "priority", 2, stringArray0);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL0);
        fail("Expecting exception: NumberFormatException");
      
      } catch(NumberFormatException e) {
         //
         // For input string: \"priority\"
         //
         verifyException("java.lang.NumberFormatException", e);
      }
  }

  @Test(timeout = 4000)
  public void test07()  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 test08()  throws Throwable  {
      URL uRL0 = URL.valueOf("m|_VWD=AYM]");
      URL uRL1 = uRL0.addParameter("rule", (CharSequence) "/r>r&^&q%(Y=o");
      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: \"(Y\"
         //
         verifyException("java.net.URLDecoder", e);
      }
  }

  @Test(timeout = 4000)
  public void test09()  throws Throwable  {
      URL uRL0 = new URL("rule", "kR\"V>4MhQM$n", (-2298), "");
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "kR\"V>4MhQM$n");
      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("rule", "kR\"V>4MhQM$n", (-2298), "");
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "kR\"V>4MhQM$n");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter0);
      assertEquals(0, int0);
  }

  @Test(timeout = 4000)
  public void test11()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "kR\"V>4MhQM$n";
      URL uRL0 = new URL("kR\"V>4MhQM$n", "kR\"V>4MhQM$n", (-2298), "kR\"V>4MhQM$n", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      int int0 = conditionRouter0.compareTo((Router) null);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test12()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "kR\"V>4MhQM$n";
      URL uRL0 = new URL("kR\"V>4MhQM$n", "", (-2298), "kR\"V>4MhQM$n", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      LinkedList<Invoker<MockInvokersSelector>> linkedList0 = new LinkedList<Invoker<MockInvokersSelector>>();
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      List<Invoker<MockInvokersSelector>> list0 = conditionRouter0.route((List<Invoker<MockInvokersSelector>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertEquals(0, list0.size());
  }

  @Test(timeout = 4000)
  public void test13()  throws Throwable  {
      String[] stringArray0 = new String[4];
      stringArray0[0] = "rule";
      stringArray0[1] = "kR\"V>4MhQM$n";
      URL uRL0 = new URL("kR\"V>4MhQM$n", "kR\"V>4MhQM$n", (-2298), "kR\"V>4MhQM$n", stringArray0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL0);
      List<Invoker<ListenerInvokerWrapper<Integer>>> list0 = conditionRouter0.route((List<Invoker<ListenerInvokerWrapper<Integer>>>) null, uRL0, (Invocation) null);
      assertNull(list0);
  }

  @Test(timeout = 4000)
  public void test14()  throws Throwable  {
      URL uRL0 = new URL("e4KFf4lvYD*Y![9;C&", "rule", (-2279), "rule");
      URL uRL1 = uRL0.addParameter("rule", (CharSequence) "e4KFf4lvYD*Y![9;C&");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"e4KFf4lvYD*Y![9;C&\", The error char '!' at index 12 before \"[9;C\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test15()  throws Throwable  {
      URL uRL0 = URL.valueOf("1ptg4f/[gt-;c");
      URL uRL1 = uRL0.addParameter("rule", (CharSequence) "/r>r&^&q(Y=o");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

  @Test(timeout = 4000)
  public void test16()  throws Throwable  {
      URL uRL0 = new URL("1ptg4f/Zgtd-;c", "1ptg4f/Zgtd-;c", (-2298));
      URL uRL1 = uRL0.addParameter("rule", (CharSequence) "f@oBmGO,BzW");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"f@oBmGO,BzW\", The error char ',' at index 7 before \"BzW\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

  @Test(timeout = 4000)
  public void test17()  throws Throwable  {
      URL uRL0 = new URL("!", "<8i9V", 2719, "rule");
      URL uRL1 = uRL0.addParameter("rule", false);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      boolean boolean0 = conditionRouter0.matchWhen(uRL0, rpcInvocation0);
      assertTrue(boolean0);
  }

  @Test(timeout = 4000)
  public void test18()  throws Throwable  {
      URL uRL0 = new URL("1ptg4f/Zgtd-;c", "1ptg4f/Zgtd-;c", (-2298));
      URL uRL1 = uRL0.addParameter("rule", (CharSequence) "provider.");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

  @Test(timeout = 4000)
  public void test19()  throws Throwable  {
      String[] stringArray0 = new String[8];
      URL uRL0 = new URL("\"2/kg0z`", "\"2/kg0z`", 0, "", 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  {
      HashMap<String, String> hashMap0 = new HashMap<String, String>();
      URL uRL0 = new URL("rule", "rule", 0, hashMap0);
      URL uRL1 = uRL0.addParameter("rule", (long) 0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = conditionRouter0.getUrl();
      assertNull(uRL2.getPassword());
  }
}
