예제 #1
0
 private int createNewPropertyKeyId(String stringKey) {
   PropertyKeyTokenStore idxStore = getPropertyKeyTokenStore();
   int keyId = (int) idxStore.nextId();
   PropertyKeyTokenRecord record = new PropertyKeyTokenRecord(keyId);
   record.setInUse(true);
   record.setCreated();
   Collection<DynamicRecord> keyRecords = idxStore.allocateNameRecords(encodeString(stringKey));
   record.setNameId((int) first(keyRecords).getId());
   record.addNameRecords(keyRecords);
   idxStore.updateRecord(record);
   propertyKeyTokens.addToken(stringKey, keyId);
   return keyId;
 }
  @Test
  public void shouldReportEmptyName() throws Exception {
    // given
    PropertyKeyTokenRecord key = inUse(new PropertyKeyTokenRecord(42));
    DynamicRecord name = addKeyName(inUse(new DynamicRecord(6)));
    key.setNameId((int) name.getId());

    // when
    ConsistencyReport.PropertyKeyTokenConsistencyReport report = check(key);

    // then
    verify(report).emptyName(name);
    verifyNoMoreInteractions(report);
  }
  @Test
  public void shouldNotReportAnythingForConsistentlyChangedRecord() throws Exception {
    // given
    PropertyKeyTokenRecord oldRecord = notInUse(new PropertyKeyTokenRecord(42));
    PropertyKeyTokenRecord newRecord = inUse(new PropertyKeyTokenRecord(42));
    DynamicRecord name = addKeyName(inUse(new DynamicRecord(6)));
    name.setData(new byte[1]);
    newRecord.setNameId((int) name.getId());

    // when
    ConsistencyReport.PropertyKeyTokenConsistencyReport report = checkChange(oldRecord, newRecord);

    // then
    verifyNoMoreInteractions(report);
  }
  @Test
  public void shouldReportProblemsWithTheNewStateWhenCheckingChanges() throws Exception {
    // given
    PropertyKeyTokenRecord oldRecord = notInUse(new PropertyKeyTokenRecord(42));
    PropertyKeyTokenRecord newRecord = inUse(new PropertyKeyTokenRecord(42));
    DynamicRecord name = addKeyName(notInUse(new DynamicRecord(6)));
    newRecord.setNameId((int) name.getId());

    // when
    ConsistencyReport.PropertyKeyTokenConsistencyReport report = checkChange(oldRecord, newRecord);

    // then
    verify(report).nameBlockNotInUse(name);
    verifyNoMoreInteractions(report);
  }
예제 #5
0
 PropertyKey(PropertyKeyTokenRecord record) {
   this.id = record.getId();
 }
예제 #6
0
파일: Command.java 프로젝트: naimdjon/neo4j
 @Override
 public String toString() {
   return record.toString();
 }
예제 #7
0
파일: Command.java 프로젝트: naimdjon/neo4j
 public PropertyKeyTokenCommand init(PropertyKeyTokenRecord record) {
   setup(record.getId(), Mode.fromRecordState(record));
   this.record = record;
   return this;
 }