forked from Azure/azure-sdk-for-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate spring cloud sample repo (Azure#14076)
* sample repo initiation * migrate spring cloud sample repo * remove duplicate dependency mangement * sync spring cloud repo update * fix readme broken link;sync storage & integration module code; * fix readme broken link * fix readme broken link * fix error * fix build errors
- Loading branch information
Showing
199 changed files
with
8,519 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...les/azure-spring-cloud-appconfiguration-conversion-sample-complete/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Release History | ||
|
||
## 1.2.8-beta.1 (Unreleased) |
9 changes: 9 additions & 0 deletions
9
...amples/azure-spring-cloud-appconfiguration-conversion-sample-complete/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Azure Spring Cloud App Configuration Conversion Sample client library for Java | ||
|
||
## Key concepts | ||
## Getting started | ||
## Key concepts | ||
## Examples | ||
## Troubleshooting | ||
## Next steps | ||
## Contributing |
82 changes: 82 additions & 0 deletions
82
...pring-boot-samples/azure-spring-cloud-appconfiguration-conversion-sample-complete/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.3.0.RELEASE</version> <!-- {x-version-update;org.springframework.boot:spring-boot-starter-parent;external_dependency} --> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>spring-cloud-azure-appconfiguration-convert-sample-complete</artifactId> | ||
<groupId>com.microsoft.azure</groupId> | ||
<version>1.2.8-beta.1</version> <!-- {x-version-update;com.microsoft.azure:spring-cloud-azure-appconfiguration-convert-sample-complete;current} --> | ||
<name>Azure Spring Cloud App Configuration Conversion Sample</name> | ||
<description>Sample project to show conversion to Azure App Configuration</description> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>Hoxton.SR7</version> <!-- {x-version-update;org.springframework.cloud:spring-cloud-dependencies;external_dependency} --> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>com.microsoft.azure</groupId> | ||
<artifactId>azure-cosmosdb-spring-boot-starter</artifactId> | ||
<version>2.3.3</version> <!-- {x-version-update;com.microsoft.azure:azure-cosmosdb-spring-boot-starter;dependency} --> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.google.guava</groupId> | ||
<artifactId>guava</artifactId> | ||
<version>25.0-jre</version> <!-- {x-version-update;cosmos_com.google.guava:guava;external_dependency} --> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.microsoft.azure</groupId> | ||
<artifactId>spring-cloud-starter-azure-appconfiguration-config</artifactId> | ||
<version>1.2.8-beta.1</version> <!-- {x-version-update;com.microsoft.azure:spring-cloud-starter-azure-appconfiguration-config;current} --> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-logging</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-api-mockito2</artifactId> | ||
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-api-mockito2;external_dependency} --> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.powermock</groupId> | ||
<artifactId>powermock-module-junit4</artifactId> | ||
<version>2.0.2</version> <!-- {x-version-update;org.powermock:powermock-module-junit4;external_dependency} --> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate.validator</groupId> | ||
<artifactId>hibernate-validator</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
75 changes: 75 additions & 0 deletions
75
...ion-conversion-sample-complete/src/main/java/sample/convert/ConvertSampleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package sample.convert; | ||
|
||
import java.util.Optional; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.util.Assert; | ||
|
||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
|
||
@SpringBootApplication | ||
public class ConvertSampleApplication implements CommandLineRunner { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(ConvertSampleApplication.class); | ||
|
||
@Autowired | ||
private UserRepository repository; | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ConvertSampleApplication.class, args); | ||
} | ||
|
||
public void run(String... var1) throws Exception { | ||
|
||
final User testUser = new User("testId", "testFirstName", "testLastName", | ||
"test address line one"); | ||
|
||
// Save the User class to Azure CosmosDB database. | ||
final Mono<User> saveUserMono = repository.save(testUser); | ||
|
||
final Flux<User> firstNameUserFlux = repository.findByFirstName("testFirstName"); | ||
|
||
// Nothing happens until we subscribe to these Monos. | ||
// findById will not return the user as user is not present. | ||
final Mono<User> findByIdMono = repository.findById(testUser.getId()); | ||
final User findByIdUser = findByIdMono.block(); | ||
Assert.isNull(findByIdUser, "User must be null"); | ||
|
||
final User savedUser = saveUserMono.block(); | ||
Assert.state(savedUser != null, | ||
"Saved user must not be null"); | ||
Assert.state(savedUser.getFirstName().equals(testUser.getFirstName()), | ||
"Saved user first name doesn't match"); | ||
|
||
firstNameUserFlux.collectList().block(); | ||
|
||
final Optional<User> optionalUserResult = repository.findById(testUser.getId()).blockOptional(); | ||
Assert.isTrue(optionalUserResult.isPresent(), "Cannot find user."); | ||
|
||
final User result = optionalUserResult.get(); | ||
Assert.state(result.getFirstName().equals(testUser.getFirstName()), | ||
"query result firstName doesn't match!"); | ||
Assert.state(result.getLastName().equals(testUser.getLastName()), | ||
"query result lastName doesn't match!"); | ||
|
||
LOGGER.info("findOne in User collection get result: {}", result.getFirstName()); | ||
} | ||
|
||
@PostConstruct | ||
public void setup() { | ||
// For this example, remove all of the existing records. | ||
this.repository.deleteAll().block(); | ||
} | ||
|
||
} |
92 changes: 92 additions & 0 deletions
92
...-cloud-appconfiguration-conversion-sample-complete/src/main/java/sample/convert/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package sample.convert; | ||
|
||
import org.springframework.data.annotation.Id; | ||
|
||
import com.microsoft.azure.spring.data.cosmosdb.core.mapping.Document; | ||
import com.microsoft.azure.spring.data.cosmosdb.core.mapping.PartitionKey; | ||
|
||
@Document(collection = "mycollection") | ||
public class User { | ||
@Id | ||
private String id; | ||
|
||
private String firstName; | ||
|
||
@PartitionKey | ||
private String lastName; | ||
|
||
private String address; | ||
|
||
public User() {} | ||
|
||
public User(String id, String firstName, String lastName, String address) { | ||
this.id = id; | ||
this.firstName = firstName; | ||
this.lastName = lastName; | ||
this.address = address; | ||
} | ||
|
||
/** | ||
* @return the id | ||
*/ | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* @param id the id to set | ||
*/ | ||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
/** | ||
* @return the firstName | ||
*/ | ||
public String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
/** | ||
* @param firstName the firstName to set | ||
*/ | ||
public void setFirstName(String firstName) { | ||
this.firstName = firstName; | ||
} | ||
|
||
/** | ||
* @return the lastName | ||
*/ | ||
public String getLastName() { | ||
return lastName; | ||
} | ||
|
||
/** | ||
* @param lastName the lastName to set | ||
*/ | ||
public void setLastName(String lastName) { | ||
this.lastName = lastName; | ||
} | ||
|
||
/** | ||
* @return the address | ||
*/ | ||
public String getAddress() { | ||
return address; | ||
} | ||
|
||
/** | ||
* @param address the address to set | ||
*/ | ||
public void setAddress(String address) { | ||
this.address = address; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s %s, %s", firstName, lastName, address); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...configuration-conversion-sample-complete/src/main/java/sample/convert/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package sample.convert; | ||
|
||
import com.microsoft.azure.spring.data.cosmosdb.repository.ReactiveCosmosRepository; | ||
import org.springframework.stereotype.Repository; | ||
import reactor.core.publisher.Flux; | ||
|
||
@Repository | ||
public interface UserRepository extends ReactiveCosmosRepository<User, String> { | ||
|
||
Flux<User> findByFirstName(String firstName); | ||
} |
1 change: 1 addition & 0 deletions
1
...cloud-appconfiguration-conversion-sample-complete/src/main/resources/bootstrap.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
spring.cloud.azure.appconfiguration.stores[0].connection-string=${CONFIG_STORE_CONNECTION_STRING} |
3 changes: 3 additions & 0 deletions
3
...ples/azure-spring-cloud-appconfiguration-conversion-sample-initial/CHANGELOG.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Release History | ||
|
||
## 1.2.8-beta.1 (Unreleased) |
Oops, something went wrong.