/*
 * This file was automatically generated by EvoSuite
 * Tue Dec 10 19:54:44 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.listener.ListenerInvokerWrapper;
import java.lang.reflect.Array;
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  {
      URL uRL0 = new URL((String) null, (String) null, (-7), "rule");
      URL uRL1 = uRL0.addParameter("rule", "~$9P8FShs");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      Class<Object>[] classArray0 = (Class<Object>[]) Array.newInstance(Class.class, 4);
      HashMap<String, String> hashMap0 = new HashMap<String, String>();
      RpcInvocation rpcInvocation0 = new RpcInvocation("A.~9|", classArray0, classArray0, hashMap0);
      boolean boolean0 = conditionRouter0.matchWhen(uRL0, rpcInvocation0);
      assertTrue(boolean0);
  }

  @Test(timeout = 4000)
  public void test01()  throws Throwable  {
      HashMap<String, String> hashMap0 = new HashMap<String, String>();
      URL uRL0 = new URL("110", "rule", 3, hashMap0);
      URL uRL1 = uRL0.addParameter("rule", (-548));
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = conditionRouter0.getUrl();
      assertSame(uRL2, uRL1);
  }

  @Test(timeout = 4000)
  public void test02()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, 31, "rule");
      URL uRL1 = uRL0.addParameter("rule", "~$9P8FShs");
      URL uRL2 = uRL1.addParameter("A.~9|", (short)0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
      ConditionRouter conditionRouter1 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter1);
      assertEquals((-49), int0);
  }

  @Test(timeout = 4000)
  public void test03()  throws Throwable  {
      URL uRL0 = new URL((String) null, "^", 778, "");
      URL uRL1 = uRL0.addParameter("priority", 0.0);
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: NumberFormatException");
      
      } catch(NumberFormatException e) {
         //
         // For input string: \"0.0\"
         //
         verifyException("java.lang.NumberFormatException", e);
      }
  }

  @Test(timeout = 4000)
  public void test04()  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 test05()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, 31, "rule");
      URL uRL1 = uRL0.addParameter("rule", "~$dg8FSh%");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalArgumentException");
      
      } catch(IllegalArgumentException e) {
         //
         // URLDecoder: Incomplete trailing escape (%) pattern
         //
         verifyException("java.net.URLDecoder", e);
      }
  }

  @Test(timeout = 4000)
  public void test06()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, (-7), "rule");
      URL uRL1 = uRL0.addParameter("rule", "~$9P8FShs");
      URL uRL2 = uRL1.addParameter("A.~9|", (short)0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
      MockInvokersSelector mockInvokersSelector0 = new MockInvokersSelector();
      int int0 = conditionRouter0.compareTo((Router) mockInvokersSelector0);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test07()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, 31, "rule");
      URL uRL1 = uRL0.addParameter("rule", "&!");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter0);
      assertEquals(0, int0);
  }

  @Test(timeout = 4000)
  public void test08()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, 31, "rule");
      URL uRL1 = uRL0.addParameter("rule", "g7<{");
      URL uRL2 = uRL1.addParameter("A.~9|", (short)0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
      int int0 = conditionRouter0.compareTo((Router) null);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test09()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, 31, "rule");
      URL uRL1 = uRL0.addParameter("rule", "rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      LinkedList<Invoker<ListenerInvokerWrapper<Integer>>> linkedList0 = new LinkedList<Invoker<ListenerInvokerWrapper<Integer>>>();
      linkedList0.add((Invoker<ListenerInvokerWrapper<Integer>>) null);
      Class<Object>[] classArray0 = (Class<Object>[]) Array.newInstance(Class.class, 5);
      HashMap<String, String> hashMap0 = new HashMap<String, String>();
      RpcInvocation rpcInvocation0 = new RpcInvocation((String) null, classArray0, classArray0, hashMap0);
      List<Invoker<ListenerInvokerWrapper<Integer>>> list0 = conditionRouter0.route((List<Invoker<ListenerInvokerWrapper<Integer>>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertFalse(list0.isEmpty());
  }

  @Test(timeout = 4000)
  public void test10()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, 31, "rule");
      URL uRL1 = uRL0.addParameter("rule", "&!");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      LinkedList<Invoker<ListenerInvokerWrapper<Integer>>> linkedList0 = new LinkedList<Invoker<ListenerInvokerWrapper<Integer>>>();
      Class<Object>[] classArray0 = (Class<Object>[]) Array.newInstance(Class.class, 5);
      HashMap<String, String> hashMap0 = new HashMap<String, String>();
      RpcInvocation rpcInvocation0 = new RpcInvocation((String) null, classArray0, classArray0, hashMap0);
      List<Invoker<ListenerInvokerWrapper<Integer>>> list0 = conditionRouter0.route((List<Invoker<ListenerInvokerWrapper<Integer>>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertEquals(0, list0.size());
  }

  @Test(timeout = 4000)
  public void test11()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, 31, "rule");
      URL uRL1 = uRL0.addParameter("rule", "g7<{");
      URL uRL2 = uRL1.addParameter("A.~9|", (short)0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
      Class<ConditionRouter>[] classArray0 = (Class<ConditionRouter>[]) Array.newInstance(Class.class, 0);
      RpcInvocation rpcInvocation0 = new RpcInvocation("A.~9|", classArray0, classArray0);
      List<Invoker<Object>> list0 = conditionRouter0.route((List<Invoker<Object>>) null, uRL2, (Invocation) rpcInvocation0);
      assertNull(list0);
  }

  @Test(timeout = 4000)
  public void test12()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, 31, "rule");
      URL uRL1 = uRL0.addParameter("rule", "r|{i!T'>X");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: IllegalStateException");
      
      } catch(IllegalStateException e) {
         //
         // Illegal route rule \"r|{i!T'>X\", The error char '!' at index 4 before \"T'>X\".
         //
         verifyException("com.alibaba.dubbo.rpc.cluster.router.condition.ConditionRouter", e);
      }
  }

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

  @Test(timeout = 4000)
  public void test14()  throws Throwable  {
      URL uRL0 = new URL((String) null, (String) null, 31);
      URL uRL1 = uRL0.addParameter("rule", "qkH=X");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

  @Test(timeout = 4000)
  public void test15()  throws Throwable  {
      HashMap<String, String> hashMap0 = new HashMap<String, String>();
      URL uRL0 = new URL("110", "rule", (short)0, hashMap0);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "p&ax[6>QmpWGl^");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

  @Test(timeout = 4000)
  public void test16()  throws Throwable  {
      URL uRL0 = new URL("", "", "", "pYj:D[}E 8y35l7", (-2134), "");
      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 test17()  throws Throwable  {
      HashMap<String, String> hashMap0 = new HashMap<String, String>();
      URL uRL0 = new URL("110", "rule", (short)0, hashMap0);
      URL uRL1 = uRL0.addParameter("rule", (int) (short)0);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = conditionRouter0.getUrl();
      assertNull(uRL2.getPath());
  }
}
