Skip to content

Commit

Permalink
fix evil whitespace indents
Browse files Browse the repository at this point in the history
  • Loading branch information
tringuyen-yw committed Jul 27, 2020
1 parent f3822a6 commit 7c0fd37
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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=?";
}
Original file line number Diff line number Diff line change
Expand Up @@ -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> 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> 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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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> journey = this.findTestJourney();
// Then
Optional<Journey> 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");
}
}

0 comments on commit 7c0fd37

Please sign in to comment.