@Test public void valuesCreatedAtCorrectLogSafetyLevelsForNewCells() { CqlQuery query = CheckAndSetQueries.getQueryForRequest(NEW_CELL_REQUEST); AtomicReference<Object[]> objects = new AtomicReference<>(); query.logSlowResult((format, args) -> objects.set(args), Stopwatch.createStarted()); Object[] loggedObjects = objects.get(); Map<String, Boolean> argumentSafety = Maps.newHashMap(); Arrays.stream(loggedObjects) .forEach(object -> { Arg<?> arg = (Arg) object; argumentSafety.put(arg.getName(), arg.isSafeForLogging()); }); assertThat(argumentSafety) .containsEntry("row", false) .containsEntry("column", false) .containsEntry("cassandraTimestamp", true) .containsEntry("newValue", false) .containsEntry("unsafeTableRef", false) .doesNotContainKey("tableRef"); assertThat(query.toString()) .isEqualTo("INSERT INTO \"ns__table\" (key, column1, column2, value)" + " VALUES (0x616263, 0x313233, -1, 0x70747074) IF NOT EXISTS;"); }
static CqlQuery getQueryForRequest(CheckAndSetRequest request) { return request.oldValue().map(unused -> updateIfMatching(request)).orElseGet(() -> insertIfNotExists(request)); }
CheckAndSetQueries { static CqlQuery getQueryForRequest(CheckAndSetRequest request) { return request.oldValue().map(unused -> updateIfMatching(request)).orElseGet(() -> insertIfNotExists(request)); } }
CheckAndSetQueries { static CqlQuery getQueryForRequest(CheckAndSetRequest request) { return request.oldValue().map(unused -> updateIfMatching(request)).orElseGet(() -> insertIfNotExists(request)); } private  CheckAndSetQueries(); }
CheckAndSetQueries { static CqlQuery getQueryForRequest(CheckAndSetRequest request) { return request.oldValue().map(unused -> updateIfMatching(request)).orElseGet(() -> insertIfNotExists(request)); } private  CheckAndSetQueries();  }
CheckAndSetQueries { static CqlQuery getQueryForRequest(CheckAndSetRequest request) { return request.oldValue().map(unused -> updateIfMatching(request)).orElseGet(() -> insertIfNotExists(request)); } private  CheckAndSetQueries();   }