/*
 * This file was automatically generated by EvoSuite
 * Tue Dec 10 19:49:04 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.AbstractMap;
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 = URL.valueOf("rule");
      URL uRL1 = uRL0.addParameter("rule", (-1.0));
      URL uRL2 = uRL0.addParameterIfAbsent("rule", "rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
      LinkedList<Invoker<ListenerInvokerWrapper<ConditionRouter>>> linkedList0 = new LinkedList<Invoker<ListenerInvokerWrapper<ConditionRouter>>>();
      Class<MockInvokersSelector>[] classArray0 = (Class<MockInvokersSelector>[]) Array.newInstance(Class.class, 4);
      InvokerWrapper<ListenerInvokerWrapper<ConditionRouter>> invokerWrapper0 = new InvokerWrapper<ListenerInvokerWrapper<ConditionRouter>>((Invoker<ListenerInvokerWrapper<ConditionRouter>>) null, uRL1);
      linkedList0.add((Invoker<ListenerInvokerWrapper<ConditionRouter>>) invokerWrapper0);
      RpcInvocation rpcInvocation0 = new RpcInvocation((String) null, classArray0, classArray0, (Map<String, String>) null);
      List<Invoker<ListenerInvokerWrapper<ConditionRouter>>> list0 = conditionRouter0.route((List<Invoker<ListenerInvokerWrapper<ConditionRouter>>>) linkedList0, uRL2, (Invocation) rpcInvocation0);
      assertFalse(list0.isEmpty());
  }

  @Test(timeout = 4000)
  public void test01()  throws Throwable  {
      URL uRL0 = URL.valueOf("rule");
      URL uRL1 = uRL0.addParameter("rule", 1805.1959874185702);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      Class<MockInvokersSelector>[] classArray0 = (Class<MockInvokersSelector>[]) Array.newInstance(Class.class, 4);
      RpcInvocation rpcInvocation0 = new RpcInvocation("-64", classArray0, classArray0, (Map<String, String>) null);
      boolean boolean0 = conditionRouter0.matchWhen(uRL0, rpcInvocation0);
      assertTrue(boolean0);
  }

  @Test(timeout = 4000)
  public void test02()  throws Throwable  {
      URL uRL0 = URL.valueOf("Failed to execute condition router rule: ");
      URL uRL1 = uRL0.addParameter("rule", (long) (byte)33);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = conditionRouter0.getUrl();
      assertEquals("Failed to execute condition router rule:", uRL2.getHost());
  }

  @Test(timeout = 4000)
  public void test03()  throws Throwable  {
      URL uRL0 = URL.valueOf("rule");
      URL uRL1 = uRL0.addParameter("rule", (-1.0));
      URL uRL2 = uRL0.addParameterIfAbsent("rule", "rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL2);
      ConditionRouter conditionRouter1 = new ConditionRouter(uRL1);
      int int0 = conditionRouter1.compareTo((Router) conditionRouter0);
      assertEquals((-69), int0);
  }

  @Test(timeout = 4000)
  public void test04()  throws Throwable  {
      URL uRL0 = new URL("-!MiW .s", "-!MiW .s", (-2244));
      URL uRL1 = uRL0.addParameter("priority", (CharSequence) "-!MiW .s");
      ConditionRouter conditionRouter0 = null;
      try {
        conditionRouter0 = new ConditionRouter(uRL1);
        fail("Expecting exception: NumberFormatException");
      
      } catch(NumberFormatException e) {
         //
         // For input string: \"-!MiW .s\"
         //
         verifyException("java.lang.NumberFormatException", e);
      }
  }

  @Test(timeout = 4000)
  public void test05()  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 test06()  throws Throwable  {
      URL uRL0 = URL.valueOf("rule");
      URL uRL1 = uRL0.addParameterIfAbsent("rule", "rule");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) conditionRouter0);
      assertEquals(0, int0);
  }

  @Test(timeout = 4000)
  public void test07()  throws Throwable  {
      URL uRL0 = URL.valueOf("rule");
      URL uRL1 = uRL0.addParameter("rule", 1805.1959874185702);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      MockInvokersSelector mockInvokersSelector0 = new MockInvokersSelector();
      int int0 = conditionRouter0.compareTo((Router) mockInvokersSelector0);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test08()  throws Throwable  {
      URL uRL0 = new URL("rule", "rule", 96, "rule", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameter("rule", (long) (byte)46);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      int int0 = conditionRouter0.compareTo((Router) null);
      assertEquals(1, int0);
  }

  @Test(timeout = 4000)
  public void test09()  throws Throwable  {
      URL uRL0 = URL.valueOf("rule");
      URL uRL1 = uRL0.addParameter("rule", 1805.1959874185702);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      LinkedList<Invoker<ListenerInvokerWrapper<ConditionRouter>>> linkedList0 = new LinkedList<Invoker<ListenerInvokerWrapper<ConditionRouter>>>();
      Class<MockInvokersSelector>[] classArray0 = (Class<MockInvokersSelector>[]) Array.newInstance(Class.class, 4);
      InvokerWrapper<ListenerInvokerWrapper<ConditionRouter>> invokerWrapper0 = new InvokerWrapper<ListenerInvokerWrapper<ConditionRouter>>((Invoker<ListenerInvokerWrapper<ConditionRouter>>) null, uRL0);
      linkedList0.add((Invoker<ListenerInvokerWrapper<ConditionRouter>>) invokerWrapper0);
      RpcInvocation rpcInvocation0 = new RpcInvocation("-64", classArray0, classArray0, (Map<String, String>) null);
      conditionRouter0.route((List<Invoker<ListenerInvokerWrapper<ConditionRouter>>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertEquals(1, linkedList0.size());
  }

  @Test(timeout = 4000)
  public void test10()  throws Throwable  {
      URL uRL0 = new URL("rule", "rule", 96, "rule", (Map<String, String>) null);
      URL uRL1 = uRL0.addParameter("rule", (long) (byte)46);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<AbstractMap.SimpleImmutableEntry<InvokerListener, InvokerListener>>> linkedList0 = new LinkedList<Invoker<AbstractMap.SimpleImmutableEntry<InvokerListener, InvokerListener>>>();
      linkedList0.add((Invoker<AbstractMap.SimpleImmutableEntry<InvokerListener, InvokerListener>>) null);
      List<Invoker<AbstractMap.SimpleImmutableEntry<InvokerListener, InvokerListener>>> list0 = conditionRouter0.route((List<Invoker<AbstractMap.SimpleImmutableEntry<InvokerListener, InvokerListener>>>) linkedList0, uRL0, (Invocation) rpcInvocation0);
      assertFalse(list0.isEmpty());
  }

  @Test(timeout = 4000)
  public void test11()  throws Throwable  {
      URL uRL0 = new URL("rule", "rule", 96);
      URL uRL1 = uRL0.addParameter("rule", 96);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      LinkedList<Invoker<AbstractMap.SimpleImmutableEntry<InvokerListener, InvokerListener>>> linkedList0 = new LinkedList<Invoker<AbstractMap.SimpleImmutableEntry<InvokerListener, InvokerListener>>>();
      List<Invoker<AbstractMap.SimpleImmutableEntry<InvokerListener, InvokerListener>>> list0 = conditionRouter0.route((List<Invoker<AbstractMap.SimpleImmutableEntry<InvokerListener, InvokerListener>>>) linkedList0, uRL1, (Invocation) rpcInvocation0);
      assertEquals(0, list0.size());
  }

  @Test(timeout = 4000)
  public void test12()  throws Throwable  {
      URL uRL0 = new URL("rule", "rule", 96);
      URL uRL1 = uRL0.addParameter("rule", 96);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      RpcInvocation rpcInvocation0 = new RpcInvocation();
      List<Invoker<ConditionRouter>> list0 = conditionRouter0.route((List<Invoker<ConditionRouter>>) null, uRL0, (Invocation) rpcInvocation0);
      assertNull(list0);
  }

  @Test(timeout = 4000)
  public void test13()  throws Throwable  {
      URL uRL0 = new URL("rule", "96", (-428712232));
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "y&Jb;VAtI(v`Y[zp");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

  @Test(timeout = 4000)
  public void test14()  throws Throwable  {
      URL uRL0 = new URL("rule", "rule", 0);
      URL uRL1 = uRL0.addParameter("rule", false);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

  @Test(timeout = 4000)
  public void test15()  throws Throwable  {
      URL uRL0 = new URL("rule", "96", 96);
      URL uRL1 = uRL0.addParameterAndEncoded("rule", "consumer.");
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
  }

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

  @Test(timeout = 4000)
  public void test17()  throws Throwable  {
      URL uRL0 = new URL((String) null, "", "", "/)Rn!O;]T#U#*%", 0, "/)Rn!O;]T#U#*%", (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 test18()  throws Throwable  {
      URL uRL0 = new URL("rule", "rule", 96);
      URL uRL1 = uRL0.addParameter("rule", 96);
      ConditionRouter conditionRouter0 = new ConditionRouter(uRL1);
      URL uRL2 = conditionRouter0.getUrl();
      assertNull(uRL2.getUsername());
  }
}
