Skip to content
Permalink
Browse files
Began changing table so that rhythm can automatically search for upco…
…ming beats across all tenants.
  • Loading branch information
mifosio-04-04-2018 committed May 15, 2017
1 parent 2f89bae commit a446ce6d8f57b0804f52cb1d979d658c7482cadb
Show file tree
Hide file tree
Showing 22 changed files with 66 additions and 567 deletions.
@@ -16,7 +16,6 @@
package io.mifos.rhythm.api.v1.client;

import io.mifos.core.api.util.CustomFeignClientsConfiguration;
import io.mifos.rhythm.api.v1.domain.Application;
import io.mifos.rhythm.api.v1.domain.Beat;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
@@ -33,29 +32,6 @@
@FeignClient(value="rhythm-v1", path="/rhythm/v1", configuration = CustomFeignClientsConfiguration.class)
public interface RhythmManager {

@RequestMapping(
value = "/applications",
method = RequestMethod.GET,
produces = MediaType.ALL_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
List<Application> getAllApplications();

@RequestMapping(
value = "/applications/{applicationname}",
method = RequestMethod.GET,
produces = MediaType.ALL_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE)
Application getApplication(@PathVariable("applicationname") final String applicationName);

@RequestMapping(
value = "/applications",
method = RequestMethod.POST,
produces = MediaType.APPLICATION_JSON_VALUE,
consumes = MediaType.APPLICATION_JSON_VALUE
)
void createApplication(final Application application);

@RequestMapping(
value = "/applications/{applicationname}",
method = RequestMethod.DELETE,

This file was deleted.

@@ -32,6 +32,11 @@ public class Beat {
public Beat() {
}

public Beat(String identifier, Integer alignmentHour) {
this.identifier = identifier;
this.alignmentHour = alignmentHour;
}

public Beat(String identifier) {
this.identifier = identifier;
}
@@ -24,12 +24,10 @@ public interface EventConstants {
String DESTINATION = "rhythm-v1";
String SELECTOR_NAME = "action";
String INITIALIZE = "initialize";
String POST_APPLICATION = "post-application";
String POST_BEAT = "post-beat";
String DELETE_APPLICATION = "delete-application";
String DELETE_BEAT = "delete-beat";
String SELECTOR_INITIALIZE = SELECTOR_NAME + " = '" + INITIALIZE + "'";
String SELECTOR_POST_APPLICATION = SELECTOR_NAME + " = '" + POST_APPLICATION + "'";
String SELECTOR_POST_BEAT = SELECTOR_NAME + " = '" + POST_BEAT + "'";
String SELECTOR_DELETE_APPLICATION = SELECTOR_NAME + " = '" + DELETE_APPLICATION + "'";
String SELECTOR_DELETE_BEAT = SELECTOR_NAME + " = '" + DELETE_BEAT + "'";

This file was deleted.

@@ -33,7 +33,7 @@ public BeatTest(ValidationTestCase<Beat> testCase) {

@Override
protected Beat createValidTestSubject() {
return new Beat();
return new Beat("boop", 0);
}

@Parameterized.Parameters
@@ -24,7 +24,6 @@
import io.mifos.core.test.listener.EnableEventRecording;
import io.mifos.core.test.listener.EventRecorder;
import io.mifos.rhythm.api.v1.client.RhythmManager;
import io.mifos.rhythm.api.v1.domain.Application;
import io.mifos.rhythm.api.v1.domain.Beat;
import io.mifos.rhythm.api.v1.events.BeatEvent;
import io.mifos.rhythm.api.v1.events.EventConstants;
@@ -118,21 +117,13 @@ public boolean waitForInitialize() {
}
}

Application createApplication(final String name) throws InterruptedException {
final Application application = new Application(name);
this.testSubject.createApplication(application);

Assert.assertTrue(this.eventRecorder.wait(EventConstants.POST_APPLICATION, application.getApplicationName()));
return application;
}

Beat createBeat(final Application application, final String beatIdentifier) throws InterruptedException {
Beat createBeat(final String applicationName, final String beatIdentifier) throws InterruptedException {
final Beat beat = new Beat();
beat.setIdentifier(beatIdentifier);
beat.setAlignmentHour(0);
this.testSubject.createBeat(application.getApplicationName(), beat);
this.testSubject.createBeat(applicationName, beat);

Assert.assertTrue(this.eventRecorder.wait(EventConstants.POST_BEAT, new BeatEvent(application.getApplicationName(), beat.getIdentifier())));
Assert.assertTrue(this.eventRecorder.wait(EventConstants.POST_BEAT, new BeatEvent(applicationName, beat.getIdentifier())));
return beat;
}
}

This file was deleted.

@@ -16,7 +16,6 @@
package io.mifos.rhythm;

import io.mifos.core.api.util.NotFoundException;
import io.mifos.rhythm.api.v1.domain.Application;
import io.mifos.rhythm.api.v1.domain.Beat;
import io.mifos.rhythm.api.v1.events.BeatEvent;
import io.mifos.rhythm.api.v1.events.EventConstants;
@@ -29,35 +28,56 @@
* @author Myrle Krantz
*/
public class TestBeats extends AbstractRhythmTest {

@Test
public void shouldCreateBeat() throws InterruptedException {
final Application application = createApplication("funnybusiness-v1");

final Beat beat = createBeat(application, "bebopthedowop");
final String appName = "funnybusiness-v1";
final Beat beat = createBeat(appName, "bebopthedowop");

final Beat createdBeat = this.testSubject.getBeat(application.getApplicationName(), beat.getIdentifier());
final Beat createdBeat = this.testSubject.getBeat(appName, beat.getIdentifier());
Assert.assertEquals(beat, createdBeat);

final List<Beat> allEntities = this.testSubject.getAllBeatsForApplication(application.getApplicationName());
final List<Beat> allEntities = this.testSubject.getAllBeatsForApplication(appName);
Assert.assertTrue(allEntities.contains(beat));
}

@Test
public void shouldDeleteBeat() throws InterruptedException {
final Application application = createApplication("funnybusiness-v2");
final String appName = "funnybusiness-v2";

final Beat beat = createBeat(application, "bebopthedowop");
final Beat beat = createBeat(appName, "bebopthedowop");

testSubject.deleteBeat(application.getApplicationName(), beat.getIdentifier());
Assert.assertTrue(this.eventRecorder.wait(EventConstants.DELETE_BEAT, new BeatEvent(application.getApplicationName(), beat.getIdentifier())));
testSubject.deleteBeat(appName, beat.getIdentifier());
Assert.assertTrue(this.eventRecorder.wait(EventConstants.DELETE_BEAT, new BeatEvent(appName, beat.getIdentifier())));

final List<Beat> allEntities = this.testSubject.getAllBeatsForApplication(application.getApplicationName());
final List<Beat> allEntities = this.testSubject.getAllBeatsForApplication(appName);
Assert.assertFalse(allEntities.contains(beat));

try {
this.testSubject.getBeat(application.getApplicationName(), beat.getIdentifier());
this.testSubject.getBeat(appName, beat.getIdentifier());
Assert.fail("NotFoundException should be thrown.");
}
catch (final NotFoundException ignored) { }
}
}
@Test
public void shouldDeleteApplication() throws InterruptedException {
final String appName = "funnybusiness-v3";
final Beat beat = createBeat(appName, "bebopthedowop");

this.testSubject.deleteApplication(appName);
Assert.assertTrue(this.eventRecorder.wait(EventConstants.DELETE_APPLICATION, appName));

final List<Beat> allEntities = this.testSubject.getAllBeatsForApplication(appName);
Assert.assertTrue(allEntities.isEmpty());
}

/*
@Test
public void shouldExecuteBeat() throws InterruptedException {
final Application application = createApplication("funnybusiness-v2");
final Beat beat = createBeat(application, "bebopthedowop");
TimeUnit.MINUTES.sleep(5);
}*/
}
@@ -38,16 +38,6 @@ public ApplicationEventListener(@SuppressWarnings("SpringJavaAutowiringInspectio
this.eventRecorder = eventRecorder;
}

@JmsListener(
subscription = EventConstants.DESTINATION,
destination = EventConstants.DESTINATION,
selector = EventConstants.SELECTOR_POST_APPLICATION
)
public void onCreateApplication(@Header(TenantHeaderFilter.TENANT_HEADER) final String tenant,
final String payload) {
this.eventRecorder.event(tenant, EventConstants.POST_APPLICATION, payload, String.class);
}

@JmsListener(
subscription = EventConstants.DESTINATION,
destination = EventConstants.DESTINATION,
@@ -52,6 +52,7 @@
"io.mifos.rhythm.service.config",
"io.mifos.rhythm.service.internal.service",
"io.mifos.rhythm.service.internal.repository",
"io.mifos.rhythm.service.internal.scheduler",
"io.mifos.rhythm.service.internal.command.handler"
})
@EnableJpaRepositories({

0 comments on commit a446ce6

Please sign in to comment.