@@ -0,0 +1,2014 @@
+package com.coding4people.mosquitoreport.api.indexers;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.fail;%0Aimport static org.mockito.Matchers.any;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport org.glassfish.hk2.api.MultiException;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0A%0Aimport com.amazonaws.services.cloudsearchv2.AmazonCloudSearch;%0Aimport com.amazonaws.services.cloudsearchv2.model.DescribeDomainsResult;%0Aimport com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;%0Aimport com.coding4people.mosquitoreport.api.Env;%0Aimport com.coding4people.mosquitoreport.api.WithService;%0Aimport com.coding4people.mosquitoreport.api.models.WithGuid;%0A%0Aimport jersey.repackaged.com.google.common.collect.Lists;%0A%0Apublic class IndexerTest extends WithService %7B%0A    @Mock%0A    AmazonCloudSearch amazonCloudSearch;%0A%0A    @Mock%0A    Env env;%0A%0A    @Test%0A    public void testThrowsExecptionWhenSearchDomainDoesNotExists() %7B%0A        when(env.get(%22MOSQUITO_REPORT_CLOUDSEARCH_DOMAIN_PREFIX%22)).thenReturn(%22test%22);%0A        when(amazonCloudSearch.describeDomains(any()))%0A                .thenReturn(new DescribeDomainsResult().withDomainStatusList(Lists.newArrayList()));%0A%0A        try %7B%0A            // TODO suppress exception stacktrace%0A            getService(ModelIndexer.class);%0A        %7D catch (MultiException e) %7B%0A            assertEquals(%22Could not find CloudSearch domain: test-model%22, e.getCause().getMessage());%0A            %0A            return;%0A        %7D%0A        %0A        fail(%22Was expection an exception%22);%0A    %7D%0A%0A    @DynamoDBTable(tableName = %22model%22)%0A    public static class Model implements WithGuid %7B%0A        private String guid;%0A%0A        @Override%0A        public String getGuid() %7B%0A            return guid;%0A        %7D%0A%0A        public void setGuid(String guid) %7B%0A            this.guid = guid;%0A        %7D%0A    %7D%0A%0A    public static class ModelIndexer extends Indexer%3CModel%3E %7B%0A        @Override%0A        protected Class%3CModel%3E getType() %7B%0A            return Model.class;%0A        %7D%0A    %7D%0A%7D%0A

Test indexer throws an execption when SearchDomain does not exists