Skip to content

DATACOUCH-661 - Fix integrations tests from 650 #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,43 @@ public String getIata() {
public String getIcao() {
return icao;
}

public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{ id: ");
sb.append(getId());
sb.append(", iata: ");
sb.append(iata);
sb.append(", icao: ");
sb.append(icao);
sb.append(" }");
return sb.toString();
}

public boolean equals(Object o) {
if (o == null) {
return false;
}
if (!(o instanceof Airport)) {
return false;
}
Airport that = (Airport) o;
if (diff(this.id,that.id)) {
return false;
}
if (diff(this.iata,that.iata)) {
return false;
}
if (diff(this.icao,that.icao)) {
return false;
}
return true;
}

private boolean diff(String s1, String s2){
if ((s1 == null && s2 != null) || !s1.equals(s2)) {
return true;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,22 @@

package org.springframework.data.couchbase.repository;

import com.couchbase.client.core.error.IndexExistsException;
import static java.util.Arrays.asList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;

import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -35,18 +50,8 @@
import org.springframework.data.couchbase.util.ClusterType;
import org.springframework.data.couchbase.util.IgnoreWhen;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import reactor.test.StepVerifier;

import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.stream.Collectors;

import static java.util.Arrays.*;
import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.*;
import com.couchbase.client.core.error.IndexExistsException;

/**
* template class for Reactive Couchbase operations
Expand All @@ -58,13 +63,10 @@
@IgnoreWhen(missesCapabilities = Capabilities.QUERY, clusterTypes = ClusterType.MOCKED)
public class ReactiveCouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegrationTests {

@Autowired
CouchbaseClientFactory clientFactory;
@Autowired CouchbaseClientFactory clientFactory;

@Autowired
ReactiveAirportRepository airportRepository; // intellij flags "Could not Autowire", but it runs ok.
@Autowired
ReactiveUserRepository userRepository; // intellij flags "Could not Autowire", but it runs ok.
@Autowired ReactiveAirportRepository airportRepository; // intellij flags "Could not Autowire", but it runs ok.
@Autowired ReactiveUserRepository userRepository; // intellij flags "Could not Autowire", but it runs ok.

@BeforeEach
void beforeEach() {
Expand Down Expand Up @@ -119,7 +121,7 @@ public void testCas() {

@Test
void count() {
String[] iatas = {"JFK", "IAD", "SFO", "SJC", "SEA", "LAX", "PHX"};
String[] iatas = { "JFK", "IAD", "SFO", "SJC", "SEA", "LAX", "PHX" };
Future[] future = new Future[iatas.length];
ExecutorService executorService = Executors.newFixedThreadPool(iatas.length);
try {
Expand All @@ -129,7 +131,7 @@ void count() {
airportRepository.save(airport).block();
}

Long airportCount = airportCount = airportRepository.count().block();
Long airportCount = airportRepository.count().block();
assertEquals(iatas.length, airportCount);

airportCount = airportRepository.countByIataIn("JFK", "IAD", "SFO").block();
Expand All @@ -154,21 +156,23 @@ void count() {
}

@Test
// DATACOUCH-650
// DATACOUCH-650
void deleteAllById() {

Airport vienna = new Airport("airports::vie", "vie", "LOWW");
Airport frankfurt = new Airport("airports::fra", "fra", "EDDF");
Airport losAngeles = new Airport("airports::lax", "lax", "KLAX");

try {
airportRepository.saveAll(asList(vienna, frankfurt, losAngeles)).as(StepVerifier::create).verifyComplete();
airportRepository.saveAll(asList(vienna, frankfurt, losAngeles)).as(StepVerifier::create)
.expectNext(vienna, frankfurt, losAngeles).verifyComplete();

airportRepository.deleteAllById(asList(vienna.getId(), losAngeles.getId())).as(StepVerifier::create).verifyComplete();
airportRepository.deleteAllById(asList(vienna.getId(), losAngeles.getId())).as(StepVerifier::create)
.verifyComplete();

airportRepository.findAll().as(StepVerifier::create).expectNext(frankfurt).verifyComplete();
} finally {
airportRepository.deleteAll();
airportRepository.deleteAll().block();
}
}

Expand Down