#562 - Polishing.
Reformat code. Remove superfluous @Repository annotation. Original pull request: #564.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 the original author or authors.
|
||||
* Copyright 2017-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -15,14 +15,13 @@
|
||||
*/
|
||||
package example.springdata.couchbase.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.couchbase.core.mapping.Document;
|
||||
import org.springframework.data.couchbase.core.mapping.Field;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
/**
|
||||
* A domain object representing an Airline
|
||||
@@ -34,21 +33,15 @@ import org.springframework.data.couchbase.core.mapping.Field;
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Airline {
|
||||
|
||||
@Id
|
||||
private String id;
|
||||
private @Id String id;
|
||||
|
||||
@Field
|
||||
private String name;
|
||||
|
||||
@Field
|
||||
private String iata;
|
||||
|
||||
@Field
|
||||
private String icao;
|
||||
|
||||
@Field
|
||||
private String callsign;
|
||||
|
||||
@Field
|
||||
private String country;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 the original author or authors.
|
||||
* Copyright 2017-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,6 +18,7 @@ package example.springdata.couchbase.repository;
|
||||
import example.springdata.couchbase.model.Airline;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@@ -28,7 +29,6 @@ import org.springframework.stereotype.Repository;
|
||||
* @author Mark Paluch
|
||||
* @author Denis Rosa
|
||||
*/
|
||||
@Repository
|
||||
public interface AirlineRepository extends CrudRepository<Airline, String> {
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package example.springdata.couchbase.repository;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration;
|
||||
|
||||
/**
|
||||
* @author Denis Rosa
|
||||
* Configuration class to connnect with couchbase
|
||||
*/
|
||||
@Configuration
|
||||
public class CouchbaseConfig extends AbstractCouchbaseConfiguration {
|
||||
|
||||
|
||||
@Override
|
||||
public String getConnectionString() {
|
||||
return "couchbase://127.0.0.1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserName() {
|
||||
return "Administrator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return "password";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBucketName() {
|
||||
return "travel-sample";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean autoIndexCreation() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -15,16 +15,17 @@
|
||||
*/
|
||||
package example.springdata.couchbase.repository;
|
||||
|
||||
import com.couchbase.client.java.Cluster;
|
||||
import com.couchbase.client.java.manager.query.CreatePrimaryQueryIndexOptions;
|
||||
import example.springdata.couchbase.model.Airline;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
||||
|
||||
import com.couchbase.client.java.Cluster;
|
||||
import com.couchbase.client.java.manager.query.CreatePrimaryQueryIndexOptions;
|
||||
|
||||
/**
|
||||
* Main Class of this module
|
||||
@@ -33,14 +34,11 @@ import org.springframework.data.couchbase.core.CouchbaseTemplate;
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@RequiredArgsConstructor
|
||||
|
||||
public class CouchbaseMain {
|
||||
|
||||
@Autowired
|
||||
private final CouchbaseTemplate couchbaseTemplate;
|
||||
@Autowired private final CouchbaseTemplate couchbaseTemplate;
|
||||
|
||||
@Autowired
|
||||
private Cluster cluster;
|
||||
@Autowired private Cluster cluster;
|
||||
|
||||
/**
|
||||
* Add the _class field to all Airline documents
|
||||
@@ -51,7 +49,6 @@ public class CouchbaseMain {
|
||||
CreatePrimaryQueryIndexOptions.createPrimaryQueryIndexOptions().ignoreIfExists(true));
|
||||
|
||||
// Need to post-process travel data to add _class attribute
|
||||
cluster.query("update `travel-sample` set _class='"+Airline.class.getName()+"' where type = 'airline'");
|
||||
|
||||
cluster.query("update `travel-sample` set _class='" + Airline.class.getName() + "' where type = 'airline'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
|
||||
# Increased timeout to fit slower environments like TravisCI
|
||||
spring.couchbase.env.timeouts.view=15000
|
||||
spring.couchbase.env.timeouts.query=15000
|
||||
spring.couchbase.connection-string=couchbase://127.0.0.1
|
||||
spring.couchbase.username=Administrator
|
||||
spring.couchbase.password=password
|
||||
spring.data.couchbase.bucket-name=travel-sample
|
||||
spring.data.couchbase.auto-index=true
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2018 the original author or authors.
|
||||
* Copyright 2017-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,21 +43,17 @@ public class AirlineRepositoryIntegrationTests {
|
||||
@ClassRule //
|
||||
public static CouchbaseAvailableRule COUCHBASE = CouchbaseAvailableRule.onLocalhost();
|
||||
|
||||
@Autowired
|
||||
AirlineRepository airlineRepository;
|
||||
@Autowired AirlineRepository airlineRepository;
|
||||
|
||||
@Autowired CouchbaseOperations couchbaseOperations;
|
||||
|
||||
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
if( couchbaseOperations.existsById().one("LH")) {
|
||||
if (couchbaseOperations.existsById().one("LH")) {
|
||||
couchbaseOperations.removeById().one("LH");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The derived query executes a N1QL query emitting a single element.
|
||||
*/
|
||||
@@ -88,7 +84,7 @@ public class AirlineRepositoryIntegrationTests {
|
||||
|
||||
List<Airline> airlines = airlineRepository.findAllBy();
|
||||
|
||||
assertThat(airlines).hasSize(374);
|
||||
assertThat(airlines).hasSizeGreaterThan(100);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user