diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
index 3269899..6285e84 100644
--- a/.idea/codeStyleSettings.xml
+++ b/.idea/codeStyleSettings.xml
@@ -130,6 +130,25 @@
+
+
+
+
+ true
+ true
+
+
+ BY_NAME
+
+
+
+
+
+ true
+
+ BY_NAME
+
+
@@ -244,17 +263,6 @@
BY_NAME
-
-
-
-
- true
- true
-
-
- BY_NAME
-
-
@@ -263,14 +271,6 @@
BY_NAME
-
-
-
- true
-
- BY_NAME
-
-
@@ -304,6 +304,5 @@
-
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 16124e6..526b31d 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,13 +11,17 @@ buildscript {
}
}
repositories {
+ maven {
+ url new File(rootProject.projectDir, "libs-reactor").toURI().toURL().toString()
+ }
mavenLocal()
jcenter()
//URL repo to get the desired compiled version
maven { url "https://jitpack.io" }
maven { url 'http://repo.spring.io/libs-snapshot' }
-}
+}
+println(new File(rootProject.projectDir, "libs-reactor").toURI().toURL().toString())
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'war'
diff --git a/gradle.properties b/gradle.properties
index 3d5a06e..26b696c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,4 @@
-version = 0.2.1
+version = 0.2.2
domainName = org.cloudfoundry
projectName = autosleep
group = org.cloudfoundry.autosleep
diff --git a/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.jar b/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.jar
new file mode 100644
index 0000000..023eded
Binary files /dev/null and b/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.jar differ
diff --git a/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.jar.sha1 b/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.jar.sha1
new file mode 100644
index 0000000..6ea6eaa
--- /dev/null
+++ b/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.jar.sha1
@@ -0,0 +1 @@
+72a192f6f081c6b64cb226e9aaaa5e3884ccb266
\ No newline at end of file
diff --git a/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.pom b/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.pom
new file mode 100644
index 0000000..dd326f4
--- /dev/null
+++ b/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.pom
@@ -0,0 +1,67 @@
+
+
+ 4.0.0
+ io.projectreactor
+ reactor-core
+ 2.5.0.BUILD-SNAPSHOT
+ Non-Blocking Reactive Foundation for the JVM
+ Non-Blocking Reactive Foundation for the JVM
+ https://github.com/reactor/reactor
+
+ reactor
+ http://github.com/reactor
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ smaldini
+ Stephane Maldini
+ smaldini@pivotal.io
+
+
+
+ scm:git:git://github.com/reactor/reactor-core
+ scm:git:git://github.com/reactor/reactor-core
+ https://github.com/reactor/reactor-core
+
+
+ GitHub Issues
+ https://github.com/reactor/reactor/issues
+
+
+
+ com.google.code.findbugs
+ jsr305
+ 3.0.0
+ compile
+ true
+
+
+ io.reactivex
+ rxjava
+ 1.0.14
+ compile
+ true
+
+
+ org.reactivestreams
+ reactive-streams
+ 1.0.0
+ compile
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.12
+ compile
+ true
+
+
+
diff --git a/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.pom.sha1 b/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.pom.sha1
new file mode 100644
index 0000000..f41bec7
--- /dev/null
+++ b/libs-reactor/io/projectreactor/reactor-core/2.5.0.BUILD-SNAPSHOT/reactor-core-2.5.0.BUILD-20160210.191749-340.pom.sha1
@@ -0,0 +1 @@
+67e1de98da0f1b110cb297c31e647e03d41d78c9
\ No newline at end of file
diff --git a/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.jar b/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.jar
new file mode 100644
index 0000000..0e81161
Binary files /dev/null and b/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.jar differ
diff --git a/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.jar.sha1 b/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.jar.sha1
new file mode 100644
index 0000000..c190937
--- /dev/null
+++ b/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.jar.sha1
@@ -0,0 +1 @@
+ce0bce42258cad0758ae32842c353c20a806279c
\ No newline at end of file
diff --git a/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.pom b/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.pom
new file mode 100644
index 0000000..a15c766
--- /dev/null
+++ b/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.pom
@@ -0,0 +1,46 @@
+
+
+ 4.0.0
+ io.projectreactor
+ reactor-stream
+ 2.5.0.BUILD-SNAPSHOT
+ Reactive Streams implementation for Reactive Extensions and more
+ Reactive Streams implementation for Reactive Extensions and more
+ https://github.com/reactor/reactor
+
+ reactor
+ http://github.com/reactor
+
+
+
+ The Apache Software License, Version 2.0
+ http://www.apache.org/licenses/LICENSE-2.0.txt
+ repo
+
+
+
+
+ smaldini
+ Stephane Maldini
+ smaldini@pivotal.io
+
+
+
+ scm:git:git://github.com/reactor/reactor-core
+ scm:git:git://github.com/reactor/reactor-core
+ https://github.com/reactor/reactor-core
+
+
+ GitHub Issues
+ https://github.com/reactor/reactor/issues
+
+
+
+ io.projectreactor
+ reactor-core
+ 2.5.0.BUILD-SNAPSHOT
+ compile
+
+
+
diff --git a/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.pom.sha1 b/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.pom.sha1
new file mode 100644
index 0000000..60e0fe5
--- /dev/null
+++ b/libs-reactor/io/projectreactor/reactor-stream/2.5.0.BUILD-SNAPSHOT/reactor-stream-2.5.0.BUILD-20160210.193010-335.pom.sha1
@@ -0,0 +1 @@
+93d4a73b796929c95a9647eeb12dea62ed930139
\ No newline at end of file
diff --git a/src/main/java/org/cloudfoundry/autosleep/dao/model/ApplicationBinding.java b/src/main/java/org/cloudfoundry/autosleep/dao/model/Binding.java
similarity index 67%
rename from src/main/java/org/cloudfoundry/autosleep/dao/model/ApplicationBinding.java
rename to src/main/java/org/cloudfoundry/autosleep/dao/model/Binding.java
index 2f17fb4..ca0ba57 100644
--- a/src/main/java/org/cloudfoundry/autosleep/dao/model/ApplicationBinding.java
+++ b/src/main/java/org/cloudfoundry/autosleep/dao/model/Binding.java
@@ -1,6 +1,11 @@
package org.cloudfoundry.autosleep.dao.model;
-import lombok.*;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import javax.persistence.Entity;
@@ -14,30 +19,29 @@
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
@Entity
-public class ApplicationBinding {
+public class Binding {
- @Id
- private String serviceBindingId;
+ public enum ResourceType {
+ Application, Route
+ }
- private String serviceInstanceId;
+ private String resourceId;
- private String applicationId;
+ private ResourceType resourceType;
+ @Id
+ private String serviceBindingId;
- @Override
- public String toString() {
- return this.getClass().getSimpleName() + " : [id:" + serviceBindingId + " serviceId:+" + serviceInstanceId
- + " app:" + applicationId + "]";
- }
+ private String serviceInstanceId;
@Override
public boolean equals(Object object) {
if (object == this) {
return true;
- } else if (!(object instanceof ApplicationBinding)) {
+ } else if (!(object instanceof Binding)) {
return false;
} else {
- ApplicationBinding other = (ApplicationBinding) object;
+ Binding other = (Binding) object;
return Objects.equals(serviceBindingId, other.serviceBindingId)
&& Objects.equals(serviceInstanceId, other.serviceInstanceId);
}
@@ -47,4 +51,10 @@ public boolean equals(Object object) {
public int hashCode() {
return serviceBindingId.hashCode();
}
+
+ @Override
+ public String toString() {
+ return this.getClass().getSimpleName() + " : [id:" + serviceBindingId + " serviceId:+" + serviceInstanceId
+ + " app:" + resourceId + "]";
+ }
}
diff --git a/src/main/java/org/cloudfoundry/autosleep/dao/repositories/BindingRepository.java b/src/main/java/org/cloudfoundry/autosleep/dao/repositories/BindingRepository.java
index cf48cd3..6bce565 100644
--- a/src/main/java/org/cloudfoundry/autosleep/dao/repositories/BindingRepository.java
+++ b/src/main/java/org/cloudfoundry/autosleep/dao/repositories/BindingRepository.java
@@ -1,8 +1,8 @@
package org.cloudfoundry.autosleep.dao.repositories;
-import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
+import org.cloudfoundry.autosleep.dao.model.Binding;
import org.springframework.data.repository.CrudRepository;
-public interface BindingRepository extends CrudRepository {
+public interface BindingRepository extends CrudRepository {
}
diff --git a/src/main/java/org/cloudfoundry/autosleep/dao/repositories/jpa/JpaBindingRepository.java b/src/main/java/org/cloudfoundry/autosleep/dao/repositories/jpa/JpaBindingRepository.java
index 4b3c478..f3da856 100644
--- a/src/main/java/org/cloudfoundry/autosleep/dao/repositories/jpa/JpaBindingRepository.java
+++ b/src/main/java/org/cloudfoundry/autosleep/dao/repositories/jpa/JpaBindingRepository.java
@@ -1,10 +1,10 @@
package org.cloudfoundry.autosleep.dao.repositories.jpa;
-import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
+import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.repositories.BindingRepository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
-public interface JpaBindingRepository extends JpaRepository, BindingRepository {
+public interface JpaBindingRepository extends JpaRepository, BindingRepository {
}
diff --git a/src/main/java/org/cloudfoundry/autosleep/ui/servicebroker/service/ApplicationBindingService.java b/src/main/java/org/cloudfoundry/autosleep/ui/servicebroker/service/ApplicationBindingService.java
index ac058b0..d77802a 100644
--- a/src/main/java/org/cloudfoundry/autosleep/ui/servicebroker/service/ApplicationBindingService.java
+++ b/src/main/java/org/cloudfoundry/autosleep/ui/servicebroker/service/ApplicationBindingService.java
@@ -2,8 +2,9 @@
import lombok.extern.slf4j.Slf4j;
import org.cloudfoundry.autosleep.config.Config;
-import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
+import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.model.ApplicationInfo;
+import org.cloudfoundry.autosleep.dao.model.Binding.ResourceType;
import org.cloudfoundry.autosleep.dao.model.SpaceEnrollerConfig;
import org.cloudfoundry.autosleep.dao.repositories.ApplicationRepository;
import org.cloudfoundry.autosleep.dao.repositories.BindingRepository;
@@ -51,9 +52,12 @@ public ServiceInstanceBinding createServiceInstanceBinding(CreateServiceInstance
log.debug("createServiceInstanceBinding - {}", bindingId);
SpaceEnrollerConfig spaceEnrollerConfig = spaceEnrollerConfigRepository.findOne(configId);
- ApplicationBinding binding = ApplicationBinding.builder().serviceInstanceId(configId)
+ Binding binding = Binding.builder()
+ .serviceInstanceId(configId)
.serviceBindingId(bindingId)
- .applicationId(appId).build();
+ .resourceId(appId)
+ .resourceType(ResourceType.Application)
+ .build();
applicationLocker.executeThreadSafe(appId, () -> {
ApplicationInfo appInfo = appRepository.findOne(appId);
if (appInfo == null) {
@@ -80,8 +84,8 @@ public ServiceInstanceBinding deleteServiceInstanceBinding(DeleteServiceInstance
final String bindingId = request.getBindingId();
log.debug("deleteServiceInstanceBinding - {}", bindingId);
- final ApplicationBinding binding = bindingRepository.findOne(bindingId);
- final String appId = binding.getApplicationId();
+ final Binding binding = bindingRepository.findOne(bindingId);
+ final String appId = binding.getResourceId();
SpaceEnrollerConfig serviceInstance = spaceEnrollerConfigRepository
.findOne(request.getInstance().getServiceInstanceId());
diff --git a/src/main/java/org/cloudfoundry/autosleep/ui/web/controller/ApiController.java b/src/main/java/org/cloudfoundry/autosleep/ui/web/controller/ApiController.java
index c7f5c99..a577734 100644
--- a/src/main/java/org/cloudfoundry/autosleep/ui/web/controller/ApiController.java
+++ b/src/main/java/org/cloudfoundry/autosleep/ui/web/controller/ApiController.java
@@ -2,7 +2,7 @@
import lombok.extern.slf4j.Slf4j;
import org.cloudfoundry.autosleep.config.Config;
-import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
+import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.model.ApplicationInfo;
import org.cloudfoundry.autosleep.dao.model.SpaceEnrollerConfig;
import org.cloudfoundry.autosleep.dao.repositories.ApplicationRepository;
@@ -67,10 +67,10 @@ public ServerResponse> listInstances() {
@RequestMapping(Config.Path.SERVICES_SUB_PATH + "{instanceId}/bindings/")
@ResponseBody
- public ServerResponse> listBindings(@PathVariable("instanceId") String serviceInstanceId)
+ public ServerResponse> listBindings(@PathVariable("instanceId") String serviceInstanceId)
throws ServiceInstanceDoesNotExistException {
log.debug("listServiceBindings - {}", serviceInstanceId);
- List result = new ArrayList<>();
+ List result = new ArrayList<>();
bindingRepository.findAll().forEach(serviceBinding -> {
if (serviceInstanceId.equals(serviceBinding.getServiceInstanceId())) {
result.add(serviceBinding);
diff --git a/src/main/java/org/cloudfoundry/autosleep/worker/WorkerManager.java b/src/main/java/org/cloudfoundry/autosleep/worker/WorkerManager.java
index 79ec8e5..865b6fe 100644
--- a/src/main/java/org/cloudfoundry/autosleep/worker/WorkerManager.java
+++ b/src/main/java/org/cloudfoundry/autosleep/worker/WorkerManager.java
@@ -50,7 +50,7 @@ public void init() {
SpaceEnrollerConfig spaceEnrollerConfig =
spaceEnrollerConfigRepository.findOne(applicationBinding.getServiceInstanceId());
if (spaceEnrollerConfig != null) {
- registerApplicationStopper(spaceEnrollerConfig, applicationBinding.getApplicationId());
+ registerApplicationStopper(spaceEnrollerConfig, applicationBinding.getResourceId());
}
});
spaceEnrollerConfigRepository.findAll().forEach(this::registerSpaceEnroller);
diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml
index 13e119b..d2316c5 100644
--- a/src/main/resources/db/changelog/db.changelog-master.yaml
+++ b/src/main/resources/db/changelog/db.changelog-master.yaml
@@ -4,7 +4,7 @@ databaseChangeLog:
author: Arnaud Ruffin
changes:
- createTable:
- tableName: ApplicationBinding
+ tableName: Binding
columns:
- column:
name: serviceBindingId
@@ -13,7 +13,10 @@ databaseChangeLog:
primaryKey: true
nullable: false
- column:
- name: applicationId
+ name: resourceId
+ type: VARCHAR(255)
+ - column:
+ name: resourceType
type: VARCHAR(255)
- column:
name: serviceInstanceId
diff --git a/src/test/java/org/cloudfoundry/autosleep/dao/repositories/BindingRepositoryTest.java b/src/test/java/org/cloudfoundry/autosleep/dao/repositories/BindingRepositoryTest.java
index 81674b2..cd1bbe4 100644
--- a/src/test/java/org/cloudfoundry/autosleep/dao/repositories/BindingRepositoryTest.java
+++ b/src/test/java/org/cloudfoundry/autosleep/dao/repositories/BindingRepositoryTest.java
@@ -2,7 +2,8 @@
import lombok.extern.slf4j.Slf4j;
import org.cloudfoundry.autosleep.dao.config.RepositoryConfig;
-import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
+import org.cloudfoundry.autosleep.dao.model.Binding;
+import org.cloudfoundry.autosleep.dao.model.Binding.ResourceType;
import org.cloudfoundry.autosleep.util.ApplicationConfiguration;
import org.junit.After;
import org.junit.Before;
@@ -43,8 +44,12 @@ public void clearDao() {
@Test
public void testInsert() {
- dao.save(ApplicationBinding.builder().serviceBindingId("testInsert")
- .serviceInstanceId("testInsert").applicationId(APP_GUID).build());
+ dao.save(Binding.builder()
+ .serviceBindingId("testInsert")
+ .serviceInstanceId("testInsert")
+ .resourceId(APP_GUID)
+ .resourceType(ResourceType.Application)
+ .build());
assertThat(countServices(), is(equalTo(1)));
}
@@ -52,9 +57,13 @@ public void testInsert() {
public void testMultipleInsertsAndRetrieves() {
List ids = Arrays.asList("testInsert1", "testInsert2");
String serviceId = "testServiceId";
- List initialList = new ArrayList<>();
- ids.forEach(id -> initialList.add(ApplicationBinding.builder().serviceBindingId(id)
- .serviceInstanceId(serviceId).applicationId(APP_GUID).build()));
+ List initialList = new ArrayList<>();
+ ids.forEach(id -> initialList.add(Binding.builder()
+ .serviceBindingId(id)
+ .serviceInstanceId(serviceId)
+ .resourceId(APP_GUID)
+ .resourceType(ResourceType.Application)
+ .build()));
//test save all
dao.save(initialList);
@@ -65,9 +74,9 @@ public void testMultipleInsertsAndRetrieves() {
ids.forEach(id -> assertThat("Each element should exist in DAO", dao.exists(id), is(true)));
//test that retrieving all elements give the same amount
- Iterable storedElement = dao.findAll();
+ Iterable storedElement = dao.findAll();
int count = 0;
- for (ApplicationBinding object : storedElement) {
+ for (Binding object : storedElement) {
count++;
}
assertTrue("Retrieving all elements should return the same quantity", count == initialList
@@ -75,7 +84,7 @@ public void testMultipleInsertsAndRetrieves() {
//test find with all inserted ids
storedElement = dao.findAll(ids);
- for (ApplicationBinding object : storedElement) {
+ for (Binding object : storedElement) {
assertTrue("Retrieved element should be the same as initial element", initialList.contains(object));
}
@@ -85,14 +94,18 @@ public void testMultipleInsertsAndRetrieves() {
public void testEquality() {
String bindingId = "bidingIdEquality";
String serviceId = "serviceIdEquality";
- ApplicationBinding original = ApplicationBinding.builder().serviceBindingId(bindingId)
- .serviceInstanceId(serviceId).applicationId(APP_GUID).build();
+ Binding original = Binding.builder()
+ .serviceBindingId(bindingId)
+ .serviceInstanceId(serviceId)
+ .resourceId(APP_GUID)
+ .resourceType(ResourceType.Application)
+ .build();
dao.save(original);
- ApplicationBinding binding = dao.findOne(bindingId);
+ Binding binding = dao.findOne(bindingId);
assertFalse("Service binding should have been found", binding == null);
assertThat(binding.getServiceInstanceId(), is(equalTo(serviceId)));
- assertThat(binding.getApplicationId(), is(equalTo(APP_GUID)));
+ assertThat(binding.getResourceId(), is(equalTo(APP_GUID)));
assertThat(binding, is(equalTo(original)));
assertTrue("Succeed in getting a binding that does not exist", dao.findOne("testGetServiceFail") == null);
@@ -111,8 +124,8 @@ public void testDelete() {
final String deleteByInstanceSuccess = "deleteByInstanceSuccess";
final String deleteByMass1 = "deleteByMass1";
final String deleteByMass2 = "deleteByMass2";
- ApplicationBinding.ApplicationBindingBuilder builder = ApplicationBinding.builder();
- builder.applicationId(APP_GUID).serviceInstanceId("service");
+ Binding.BindingBuilder builder = Binding.builder();
+ builder.resourceId(APP_GUID).resourceType(ResourceType.Application).serviceInstanceId("service");
dao.save(builder.serviceBindingId(deleteByIdSuccess).build());
dao.save(builder.serviceBindingId(deleteByInstanceSuccess).build());
dao.save(builder.serviceBindingId(deleteByMass1).build());
@@ -130,7 +143,7 @@ public void testDelete() {
assertThat(countServices(), is(equalTo(nbServicesInit - 2)));
//delete multiple services
- Iterable services = dao.findAll(Arrays.asList(deleteByMass1, deleteByMass2));
+ Iterable services = dao.findAll(Arrays.asList(deleteByMass1, deleteByMass2));
dao.delete(services);
assertThat(countServices(), is(equalTo(nbServicesInit - 4)));
diff --git a/src/test/java/org/cloudfoundry/autosleep/ui/servicebroker/service/ApplicationBindingServiceTest.java b/src/test/java/org/cloudfoundry/autosleep/ui/servicebroker/service/BindingServiceTest.java
similarity index 92%
rename from src/test/java/org/cloudfoundry/autosleep/ui/servicebroker/service/ApplicationBindingServiceTest.java
rename to src/test/java/org/cloudfoundry/autosleep/ui/servicebroker/service/BindingServiceTest.java
index 3c7fb8f..2e67f99 100644
--- a/src/test/java/org/cloudfoundry/autosleep/ui/servicebroker/service/ApplicationBindingServiceTest.java
+++ b/src/test/java/org/cloudfoundry/autosleep/ui/servicebroker/service/BindingServiceTest.java
@@ -1,8 +1,9 @@
package org.cloudfoundry.autosleep.ui.servicebroker.service;
import lombok.extern.slf4j.Slf4j;
-import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
+import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.model.ApplicationInfo;
+import org.cloudfoundry.autosleep.dao.model.Binding.ResourceType;
import org.cloudfoundry.autosleep.dao.model.SpaceEnrollerConfig;
import org.cloudfoundry.autosleep.dao.repositories.ApplicationRepository;
import org.cloudfoundry.autosleep.dao.repositories.BindingRepository;
@@ -33,7 +34,7 @@
@RunWith(MockitoJUnitRunner.class)
@Slf4j
-public class ApplicationBindingServiceTest {
+public class BindingServiceTest {
private static final UUID APP_UID = UUID.randomUUID();
@@ -104,7 +105,7 @@ public void testCreateServiceInstanceBinding() throws Exception {
bindingService.createServiceInstanceBinding(createRequestTemplate.withServiceInstanceId("Sid").withBindingId(
"Bid"));
verify(appRepo, times(1)).save(any(ApplicationInfo.class));
- verify(bindingRepo, times(1)).save(any(ApplicationBinding.class));
+ verify(bindingRepo, times(1)).save(any(Binding.class));
verify(workerManager, times(1)).registerApplicationStopper(any(SpaceEnrollerConfig.class), anyString());
when(appRepo.findOne(APP_UID.toString())).thenReturn(applicationInfo);
@@ -116,9 +117,12 @@ private DeleteServiceInstanceBindingRequest prepareDeleteTest(String serviceId ,
when(appRepo.findOne(APP_UID.toString())).thenReturn(applicationInfo);
when(bindingRepo.findOne(bindingId))
- .thenReturn(ApplicationBinding.builder().serviceBindingId(bindingId)
+ .thenReturn(Binding.builder()
+ .serviceBindingId(bindingId)
.serviceInstanceId(serviceId)
- .applicationId(APP_UID.toString()).build());
+ .resourceId(APP_UID.toString())
+ .resourceType(ResourceType.Application)
+ .build());
return new DeleteServiceInstanceBindingRequest(bindingId,
serviceInstance,
diff --git a/src/test/java/org/cloudfoundry/autosleep/ui/web/controller/ApiControllerTest.java b/src/test/java/org/cloudfoundry/autosleep/ui/web/controller/ApiControllerTest.java
index b584974..13e494f 100644
--- a/src/test/java/org/cloudfoundry/autosleep/ui/web/controller/ApiControllerTest.java
+++ b/src/test/java/org/cloudfoundry/autosleep/ui/web/controller/ApiControllerTest.java
@@ -4,8 +4,9 @@
import com.fasterxml.jackson.databind.type.TypeFactory;
import org.cloudfoundry.autosleep.config.Config;
import org.cloudfoundry.autosleep.config.Config.CloudFoundryAppState;
-import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
+import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.model.ApplicationInfo;
+import org.cloudfoundry.autosleep.dao.model.Binding.ResourceType;
import org.cloudfoundry.autosleep.dao.model.SpaceEnrollerConfig;
import org.cloudfoundry.autosleep.dao.repositories.ApplicationRepository;
import org.cloudfoundry.autosleep.dao.repositories.BindingRepository;
@@ -126,9 +127,12 @@ public void testListInstances() throws Exception {
@Test
public void testListBindings() throws Exception {
- ApplicationBinding serviceBinding = ApplicationBinding.builder().serviceBindingId(serviceBindingId)
+ Binding serviceBinding = Binding.builder()
+ .serviceBindingId(serviceBindingId)
.serviceInstanceId(serviceInstanceId)
- .applicationId(UUID.randomUUID().toString()).build();
+ .resourceId(UUID.randomUUID().toString())
+ .resourceType(ResourceType.Application)
+ .build();
when(bindingRepository.findAll()).thenReturn(Collections.singletonList(serviceBinding));
mockMvc.perform(get(Config.Path.API_CONTEXT + Config.Path.SERVICES_SUB_PATH + serviceInstanceId + "/bindings/")
@@ -138,11 +142,11 @@ public void testListBindings() throws Exception {
Collections.singletonMap("charset", Charset.forName("UTF-8").toString()))))
.andDo(mvcResult -> {
verify(bindingRepository, times(1)).findAll();
- ServerResponse serviceBindings = objectMapper
+ ServerResponse serviceBindings = objectMapper
.readValue(mvcResult.getResponse().getContentAsString(),
TypeFactory.defaultInstance()
.constructParametricType(ServerResponse.class,
- ApplicationBinding[].class));
+ Binding[].class));
assertThat(serviceBindings.getBody(), is(notNullValue()));
assertThat(serviceBindings.getBody().length, is(equalTo(1)));
assertThat(serviceBindings.getBody()[0].getServiceBindingId(), is(equalTo(serviceBindingId)));
@@ -157,11 +161,11 @@ public void testListBindings() throws Exception {
Collections.singletonMap("charset", Charset.forName("UTF-8").toString()))))
.andDo(mvcResult -> {
verify(bindingRepository, times(2)).findAll();
- ServerResponse serviceBindings = objectMapper
+ ServerResponse serviceBindings = objectMapper
.readValue(mvcResult.getResponse().getContentAsString(),
TypeFactory.defaultInstance()
.constructParametricType(ServerResponse.class,
- ApplicationBinding[].class));
+ Binding[].class));
assertThat(serviceBindings.getBody(), is(notNullValue()));
assertThat(serviceBindings.getBody().length, is(equalTo(0)));
});
diff --git a/src/test/java/org/cloudfoundry/autosleep/util/BeanGenerator.java b/src/test/java/org/cloudfoundry/autosleep/util/BeanGenerator.java
index d15ec7b..f75edd5 100644
--- a/src/test/java/org/cloudfoundry/autosleep/util/BeanGenerator.java
+++ b/src/test/java/org/cloudfoundry/autosleep/util/BeanGenerator.java
@@ -1,7 +1,8 @@
package org.cloudfoundry.autosleep.util;
-import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
+import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.model.ApplicationInfo;
+import org.cloudfoundry.autosleep.dao.model.Binding.ResourceType;
import org.cloudfoundry.autosleep.dao.model.SpaceEnrollerConfig;
import org.cloudfoundry.autosleep.worker.remote.model.ApplicationIdentity;
@@ -69,7 +70,7 @@ public static ApplicationInfo.DiagnosticInfo.ApplicationLog createAppLog() {
return createAppLog(null);
}
- public static ApplicationBinding createBinding(String serviceId, String bindingId, String appId) {
+ public static Binding createBinding(String serviceId, String bindingId, String appId) {
if (serviceId == null) {
serviceId = UUID.randomUUID().toString();
}
@@ -79,11 +80,15 @@ public static ApplicationBinding createBinding(String serviceId, String bindingI
if (appId == null) {
appId = UUID.randomUUID().toString();
}
- return ApplicationBinding.builder().serviceBindingId(bindingId)
- .serviceInstanceId(serviceId).applicationId(appId).build();
+ return Binding.builder()
+ .serviceBindingId(bindingId)
+ .serviceInstanceId(serviceId)
+ .resourceId(appId)
+ .resourceType(ResourceType.Application)
+ .build();
}
- public static ApplicationBinding createBinding() {
+ public static Binding createBinding() {
return createBinding(null, null, null);
}
diff --git a/src/test/java/org/cloudfoundry/autosleep/worker/WorkerManagerTest.java b/src/test/java/org/cloudfoundry/autosleep/worker/WorkerManagerTest.java
index 510682e..d9c4329 100644
--- a/src/test/java/org/cloudfoundry/autosleep/worker/WorkerManagerTest.java
+++ b/src/test/java/org/cloudfoundry/autosleep/worker/WorkerManagerTest.java
@@ -3,7 +3,7 @@
import lombok.extern.slf4j.Slf4j;
import org.cloudfoundry.autosleep.config.Config;
import org.cloudfoundry.autosleep.config.DeployedApplicationConfig;
-import org.cloudfoundry.autosleep.dao.model.ApplicationBinding;
+import org.cloudfoundry.autosleep.dao.model.Binding;
import org.cloudfoundry.autosleep.dao.model.SpaceEnrollerConfig;
import org.cloudfoundry.autosleep.dao.repositories.ApplicationRepository;
import org.cloudfoundry.autosleep.dao.repositories.BindingRepository;
@@ -90,7 +90,7 @@ public void populateDb() throws CloudFoundryException {
}).when(applicationLocker).executeThreadSafe(anyString(), any(Runnable.class));
//init mock binding repository with unattached binding
- List storedBindings = unattachedBinding.stream()
+ List storedBindings = unattachedBinding.stream()
.map(id -> BeanGenerator.createBinding())
.collect(Collectors.toList());