diff --git a/week3-AppDev-crud/crud-java/src/main/java/com/datastax/workshop/JourneyRepository.java b/week3-AppDev-crud/crud-java/src/main/java/com/datastax/workshop/JourneyRepository.java index 75b47ac0..44862b67 100644 --- a/week3-AppDev-crud/crud-java/src/main/java/com/datastax/workshop/JourneyRepository.java +++ b/week3-AppDev-crud/crud-java/src/main/java/com/datastax/workshop/JourneyRepository.java @@ -74,13 +74,13 @@ public UUID create(String spacecraft, String journeySummary) { * Check result with * select journey_id, spacecraft_name,summary,start,end,active from killrvideo.spacecraft_journey_catalog; */ - public void takeoff(UUID journeyId, String spacecraft) { - cqlSession.execute(SimpleStatement.builder(SOLUTION_TAKEOFF) - .addPositionalValue(Instant.now()) - .addPositionalValue(spacecraft) - .addPositionalValue(journeyId) - .build()); - } + public void takeoff(UUID journeyId, String spacecraft) { + cqlSession.execute(SimpleStatement.builder(SOLUTION_TAKEOFF) + .addPositionalValue(Instant.now()) + .addPositionalValue(spacecraft) + .addPositionalValue(journeyId) + .build()); + } /** * Save a few readings @@ -157,13 +157,13 @@ public void log(UUID journeyId, String spacecraft, double speed, cqlSession.execute(bb.build()); } - public void landing(UUID journeyId, String spacecraft) { - cqlSession.execute(SimpleStatement.builder(SOLUTION_LANDING) - .addPositionalValue(Instant.now()) - .addPositionalValue(spacecraft) - .addPositionalValue(journeyId) - .build()); - } + public void landing(UUID journeyId, String spacecraft) { + cqlSession.execute(SimpleStatement.builder(SOLUTION_LANDING) + .addPositionalValue(Instant.now()) + .addPositionalValue(spacecraft) + .addPositionalValue(journeyId) + .build()); + } public void delete(String spacecraft, UUID journeyId) { BatchStatementBuilder bb = new BatchStatementBuilder(BatchType.LOGGED); @@ -262,20 +262,20 @@ private SimpleStatement deleteLocationsStmt(String spacecraft, UUID journeyId) { // == SOLUTIONS == private static final String SOLUTION_INSERT = - "INSERT INTO spacecraft_journey_catalog (spacecraft_name, journey_id, active, summary) " - + "VALUES(?,?,?,?)"; + "INSERT INTO spacecraft_journey_catalog (spacecraft_name, journey_id, active, summary) " + + "VALUES(?,?,?,?)"; - private static final String SOLUTION_TAKEOFF = - "UPDATE spacecraft_journey_catalog " - + "SET active=true, start=? " - + "WHERE spacecraft_name=? AND journey_id=?"; + private static final String SOLUTION_TAKEOFF = + "UPDATE spacecraft_journey_catalog " + + "SET active=true, start=? " + + "WHERE spacecraft_name=? AND journey_id=?"; - private static final String SOLUTION_LANDING = - "UPDATE spacecraft_journey_catalog " - + "SET active=false, end=? " - + "WHERE spacecraft_name=? AND journey_id=?"; + private static final String SOLUTION_LANDING = + "UPDATE spacecraft_journey_catalog " + + "SET active=false, end=? " + + "WHERE spacecraft_name=? AND journey_id=?"; private static final String SOLUTION_READ_JOURNEY = - "SELECT * FROM spacecraft_journey_catalog " - + "WHERE spacecraft_name=? AND journey_id=?"; + "SELECT * FROM spacecraft_journey_catalog " + + "WHERE spacecraft_name=? AND journey_id=?"; } diff --git a/week3-AppDev-crud/crud-java/src/test/java/com/datastax/workshop/Ex04_Query5b_TakeOff.java b/week3-AppDev-crud/crud-java/src/test/java/com/datastax/workshop/Ex04_Query5b_TakeOff.java index 4d9222b4..d8f63d5d 100644 --- a/week3-AppDev-crud/crud-java/src/test/java/com/datastax/workshop/Ex04_Query5b_TakeOff.java +++ b/week3-AppDev-crud/crud-java/src/test/java/com/datastax/workshop/Ex04_Query5b_TakeOff.java @@ -15,43 +15,43 @@ @RunWith(JUnitPlatform.class) public class Ex04_Query5b_TakeOff extends TestFixtures implements DataModelConstants { - /** - * CHECK on Astra CQL Console: - * Must see: active=true, 'start' has valid timestamp - * SELECT * FROM killrvideo.spacecraft_journey_catalog WHERE spacecraft_name='Crew Dragon Endeavour,SpaceX' AND journey_id=8dfd0a30-c73b-11ea-b87b-1325d5aaa06b; - */ - @Test - public void takeoff_the_spacecraft() { - // When - LOGGER.info("9..8..7..6..5..4..3..2..1 Ignition"); - journeyRepo.takeoff( - UUID.fromString(this.TEST_JOURNEYID), - this.TEST_SPACECRAFT - ); - LOGGER.info("Journey {} has now taken off", this.TEST_JOURNEYID); - - // Then - Optional journey = this.findTestJourney(); - - Assertions.assertTrue(journey.isPresent(), - String.format( - "spacecraft_journey_catalog should have a row with\n" + - "spacecraft_name = '%s'" + - "journey_id = %s", - this.TEST_SPACECRAFT, - this.TEST_JOURNEYID) - ); - - Assertions.assertTrue( - journey.get().isActive(), - "Journey takeoff should set active = true" - ); - - Assertions.assertTrue( - journey.get().getStart().compareTo(Instant.now()) <= 0, - "Journey start timestamp should be <= now()" - ); - - LOGGER.info("SUCCESS"); - } + /** + * CHECK on Astra CQL Console: + * Must see: active=true, 'start' has valid timestamp + * SELECT * FROM killrvideo.spacecraft_journey_catalog WHERE spacecraft_name='Crew Dragon Endeavour,SpaceX' AND journey_id=8dfd0a30-c73b-11ea-b87b-1325d5aaa06b; + */ + @Test + public void takeoff_the_spacecraft() { + // When + LOGGER.info("9..8..7..6..5..4..3..2..1 Ignition"); + journeyRepo.takeoff( + UUID.fromString(this.TEST_JOURNEYID), + this.TEST_SPACECRAFT + ); + LOGGER.info("Journey {} has now taken off", this.TEST_JOURNEYID); + + // Then + Optional journey = this.findTestJourney(); + + Assertions.assertTrue(journey.isPresent(), + String.format( + "spacecraft_journey_catalog should have a row with\n" + + "spacecraft_name = '%s'" + + "journey_id = %s", + this.TEST_SPACECRAFT, + this.TEST_JOURNEYID) + ); + + Assertions.assertTrue( + journey.get().isActive(), + "Journey takeoff should set active = true" + ); + + Assertions.assertTrue( + journey.get().getStart().compareTo(Instant.now()) <= 0, + "Journey start timestamp should be <= now()" + ); + + LOGGER.info("SUCCESS"); + } } diff --git a/week3-AppDev-crud/crud-java/src/test/java/com/datastax/workshop/Ex06_Query5d_Landing.java b/week3-AppDev-crud/crud-java/src/test/java/com/datastax/workshop/Ex06_Query5d_Landing.java index af1fc4c9..9224ae76 100644 --- a/week3-AppDev-crud/crud-java/src/test/java/com/datastax/workshop/Ex06_Query5d_Landing.java +++ b/week3-AppDev-crud/crud-java/src/test/java/com/datastax/workshop/Ex06_Query5d_Landing.java @@ -15,53 +15,53 @@ @RunWith(JUnitPlatform.class) public class Ex06_Query5d_Landing extends TestFixtures implements DataModelConstants { - @Test - /** - * CHECK on Astra CQL Console: - * Must see: active=false, 'end' has valid timestamp - * SELECT * FROM killrvideo.spacecraft_journey_catalog WHERE spacecraft_name='Crew Dragon Endeavour,SpaceX' AND journey_id=8dfd0a30-c73b-11ea-b87b-1325d5aaa06b; - */ - public void landing_journey() { - // When - journeyRepo.landing( - UUID.fromString(this.TEST_JOURNEYID), - this.TEST_SPACECRAFT - ); - LOGGER.info("Journey {} has now landed", this.TEST_JOURNEYID); + @Test + /** + * CHECK on Astra CQL Console: + * Must see: active=false, 'end' has valid timestamp + * SELECT * FROM killrvideo.spacecraft_journey_catalog WHERE spacecraft_name='Crew Dragon Endeavour,SpaceX' AND journey_id=8dfd0a30-c73b-11ea-b87b-1325d5aaa06b; + */ + public void landing_journey() { + // When + journeyRepo.landing( + UUID.fromString(this.TEST_JOURNEYID), + this.TEST_SPACECRAFT + ); + LOGGER.info("Journey {} has now landed", this.TEST_JOURNEYID); - // Then - Optional journey = this.findTestJourney(); + // Then + Optional journey = this.findTestJourney(); - Assertions.assertTrue(journey.isPresent(), - String.format( - "spacecraft_journey_catalog should have a row with\n" + - "spacecraft_name = '%s'" + - "journey_id = %s", - this.TEST_SPACECRAFT, - this.TEST_JOURNEYID) - ); + Assertions.assertTrue(journey.isPresent(), + String.format( + "spacecraft_journey_catalog should have a row with\n" + + "spacecraft_name = '%s'" + + "journey_id = %s", + this.TEST_SPACECRAFT, + this.TEST_JOURNEYID) + ); - Assertions.assertFalse( - journey.get().isActive(), - "Journey takeoff should set active = false" - ); + Assertions.assertFalse( + journey.get().isActive(), + "Journey takeoff should set active = false" + ); - Instant startTimestamp = journey.get().getStart(); - Instant endTimestamp = journey.get().getEnd(); + Instant startTimestamp = journey.get().getStart(); + Instant endTimestamp = journey.get().getEnd(); - Assertions.assertTrue( - endTimestamp.compareTo(Instant.now()) <= 0, - "Journey end timestamp should be <= now()" - ); + Assertions.assertTrue( + endTimestamp.compareTo(Instant.now()) <= 0, + "Journey end timestamp should be <= now()" + ); - Assertions.assertTrue( - endTimestamp.isAfter(startTimestamp), - String.format( - "Journey end timestamp (%s) should be < start timestamp (%s)", - endTimestamp.toString(), - startTimestamp.toString()) - ); + Assertions.assertTrue( + endTimestamp.isAfter(startTimestamp), + String.format( + "Journey end timestamp (%s) should be < start timestamp (%s)", + endTimestamp.toString(), + startTimestamp.toString()) + ); - LOGGER.info("SUCCESS"); - } + LOGGER.info("SUCCESS"); + } }