package org.springframework.content.s3.boot;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;

import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.junit.Test;

import org.springframework.boot.autoconfigure.AutoConfigurationPackage;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.content.commons.annotations.Content;
import org.springframework.content.commons.annotations.ContentId;
import org.springframework.content.commons.repository.ContentStore;
import org.springframework.content.s3.config.AbstractS3ContentRepositoryConfiguration;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.JpaRepository;

public class ContentS3AutoConfigurationTests {

	@Test
	public void contextLoads() {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
		context.register(TestConfig.class);
		context.refresh();

		MatcherAssert.assertThat(context.getBean(TestEntityContentRepository.class), CoreMatchers.is(CoreMatchers.not(CoreMatchers.nullValue())));

		context.close();
	}

	@Configuration
	@AutoConfigurationPackage
	@EnableAutoConfiguration
	public static class TestConfig extends AbstractS3ContentRepositoryConfiguration {
		@Override
		public String bucket() {
			return "spring-eg-content-s3";
		}
		@Override
		public Region region() {
			return Region.getRegion(Regions.US_WEST_1);
		}
	}

	@Entity
	@Content
	public class TestEntity {
		@Id
		@GeneratedValue(strategy = GenerationType.AUTO)
		private String id;
		@ContentId
		private String contentId;
	}

	public interface TestEntityRepository extends JpaRepository<TestEntity, Long> {
	}

	public interface TestEntityContentRepository extends ContentStore<TestEntity, String> {
	}
}

@@ -258,16 +258,59 @@
 Regions;
+%0Aimport com.amazonaws.services.s3.AmazonS3;
 %0A%0Aimport
@@ -395,17 +395,79 @@
 t.Test;%0A
+import org.springframework.beans.factory.annotation.Autowired;
 %0A
-
 import o
@@ -531,16 +531,16 @@
 ckage;%0A%0A
-
 import o
@@ -594,32 +594,109 @@
 oConfiguration;%0A
+import org.springframework.cloud.aws.core.io.s3.SimpleStorageResourceLoader;%0A
 import org.sprin
@@ -1721,16 +1721,58 @@
 ation %7B%0A
+%0A%09%09@Autowired%0A%09%09private AmazonS3 client;%0A%0A
 %09%09@Overr
@@ -1929,16 +1929,190 @@
 _1);%0A%09%09%7D
+%0A%0A%09%09@Override%0A%09%09public SimpleStorageResourceLoader simpleStorageResourceLoader() %7B%0A%09        client.setRegion(region());%0A%09%09%09return new SimpleStorageResourceLoader(client);%0A%09%09%7D
 %0A%09%7D%0A%0A%09@E

Add missing config to s3-boot-starter