Ejemplo n.º 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);
  }
Ejemplo n.º 5
0
 PropertyKey(PropertyKeyTokenRecord record) {
   this.id = record.getId();
 }
Ejemplo n.º 6
0
 @Override
 public String toString() {
   return record.toString();
 }
Ejemplo n.º 7
0
 public PropertyKeyTokenCommand init(PropertyKeyTokenRecord record) {
   setup(record.getId(), Mode.fromRecordState(record));
   this.record = record;
   return this;
 }