### Question:
AmbariSolrCloudClient { public String createCollection() throws Exception { List<String> collections = listCollections(); if (!collections.contains(getCollection())) { String collection = new CreateCollectionCommand(getRetryTimes(), getInterval()).run(this); LOG.info("Collection '{}' creation request sent.", collection); } else { LOG.info("Collection '{}' already exits.", getCollection()); if (this.isImplicitRouting()) { createShard(null); } } return getCollection(); } AmbariSolrCloudClient(AmbariSolrCloudClientBuilder builder); List<String> listCollections(); String createCollection(); String outputCollectionData(); void setClusterProp(); void createZnode(); boolean isZnodeExists(String znode); void setupKerberosPlugin(); void secureSolrZnode(); void secureZnode(); void unsecureZnode(); String uploadConfiguration(); String downloadConfiguration(); boolean configurationExists(); Collection<String> createShard(String shard); Collection<String> getShardNames(); Collection<String> getSolrHosts(); boolean removeAdminHandlerFromCollectionConfig(); boolean transferZnode(); boolean deleteZnode(); String getZkConnectString(); String getCollection(); String getConfigSet(); String getConfigDir(); int getShards(); int getReplication(); int getRetryTimes(); int getInterval(); CloudSolrClient getSolrCloudClient(); SolrZkClient getSolrZkClient(); int getMaxShardsPerNode(); String getRouterName(); String getRouterField(); boolean isImplicitRouting(); String getJaasFile(); String getSaslUsers(); String getZnode(); String getPropName(); String getPropValue(); boolean isSecure(); String getSecurityJsonLocation(); String getTransferMode(); String getCopySrc(); String getCopyDest(); String getOutput(); boolean isIncludeDocNumber();  }### Answer:
@Test public void testCreateCollectionWhenCollectionDoesNotExist() throws Exception { NamedList<Object> namedList = new NamedList<>(); namedList.add("collections", Arrays.asList("collection1", "collection2")); expect(mockedSolrClient.request(anyObject(CollectionAdminRequest.class), anyString())).andReturn(namedList).times(1); replay(mockedSolrClient); String result = underTest.createCollection(); assertEquals("collection1", result); verify(mockedSolrClient); }
@Test public void testCreateCollectionWhenCollectionExists() throws Exception { NamedList<Object> namedList = new NamedList<>(); namedList.add("collections", Arrays.asList("collection2", "collection3")); expect(mockedSolrClient.request(anyObject(CollectionAdminRequest.class), anyString())).andReturn(namedList).times(2); replay(mockedSolrClient); String result = underTest.createCollection(); assertEquals("collection1", result); verify(mockedSolrClient); }