use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class SchemaChangeLogServiceImplTest method getSchemaChangeLogs.
@Test
public void getSchemaChangeLogs() {
// Given
final int numSchemaChangeLogs = random.nextInt(100) + 1;
final List<SchemaChangeLog> schemaChangeLogs = new ArrayList<>(numSchemaChangeLogs);
for (int i = 0; i < numSchemaChangeLogs; i++) {
int order = i + 1;
schemaChangeLogs.add(newSchemaChangeLog("id" + order, order));
}
when(schemaChangeLogDao.getChangeLogs(anyString())).thenReturn(schemaChangeLogs);
// When
List<SchemaChangeLog> actualSchemaChangeLogs = schemaChangeLogService.getSchemaChangeLogs("namespace");
// Then
for (int i = 0; i < actualSchemaChangeLogs.size(); i++) {
final SchemaChangeLog actualSchemaChangeLog = actualSchemaChangeLogs.get(i);
final int expectedOrder = i + 1;
final String expectedId = "id" + expectedOrder;
MatcherAssert.assertThat(actualSchemaChangeLog.getId(), equalTo(expectedId));
MatcherAssert.assertThat(actualSchemaChangeLog.getExecOrder(), equalTo(expectedOrder));
}
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class SchemaChangeLogServiceImplTest method recordChangeSets.
@Test
public void recordChangeSets() {
// Given
final int numChangeSets = random.nextInt(100) + 1;
final List<ChangeSet> changeSets = new ArrayList<>(numChangeSets);
for (int i = 0; i < numChangeSets; i++) {
changeSets.add(newChangeSet("id" + (i + 1)));
}
doNothing().when(schemaChangeLogDao).insertChangeLog(anyString(), any(SchemaChangeLog.class));
// When
List<SchemaChangeLog> schemaChangeLogs = schemaChangeLogService.recordChangeSets("namespace", changeSets);
// Then
MatcherAssert.assertThat(schemaChangeLogs.size(), equalTo(numChangeSets));
final int initialExecOrder = 1;
for (int i = 0; i < numChangeSets; i++) {
SchemaChangeLog schemaChangeLog = schemaChangeLogs.get(i);
ChangeSet changeSet = changeSets.get(i);
MatcherAssert.assertThat(schemaChangeLog.getId(), equalTo(changeSet.getId()));
int expectedExecOrder = initialExecOrder + i;
MatcherAssert.assertThat(schemaChangeLog.getExecOrder(), equalTo(expectedExecOrder));
}
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class SchemaChangeLogServiceImplTest method getSchemaChangeLogs_shouldFailOnDuplicateId.
@Test(expected = IllegalStateException.class)
public void getSchemaChangeLogs_shouldFailOnDuplicateId() {
// Given
final int numSchemaChangeLogs = random.nextInt(100) + 1;
final List<SchemaChangeLog> schemaChangeLogs = new ArrayList<>();
int order = 1;
for (int i = 0; i < numSchemaChangeLogs; i++) {
schemaChangeLogs.add(newSchemaChangeLog("id" + order, order));
order++;
}
// add duplicate element
final String duplicateId = "id" + (random.nextInt(numSchemaChangeLogs) + 1);
schemaChangeLogs.add(newSchemaChangeLog(duplicateId, order));
when(schemaChangeLogDao.getChangeLogs(anyString())).thenReturn(schemaChangeLogs);
// When
schemaChangeLogService.getSchemaChangeLogs("namespace");
// Then
Assert.fail();
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class SchemaChangeLogServiceImplTest method recordChangeSet.
@Test
public void recordChangeSet() {
// Given
final ChangeSet changeSet = newChangeSet("id1");
doNothing().when(schemaChangeLogDao).insertChangeLog(anyString(), any(SchemaChangeLog.class));
// When
SchemaChangeLog schemaChangeLog = schemaChangeLogService.recordChangeSet("namespace", changeSet);
// Then
MatcherAssert.assertThat(schemaChangeLog.getId(), equalTo(changeSet.getId()));
MatcherAssert.assertThat(schemaChangeLog.getExecOrder(), equalTo(1));
}
use of com.navercorp.pinpoint.hbase.schema.domain.SchemaChangeLog in project pinpoint by naver.
the class SchemaChangeLogServiceImplTest method recordChangeSets_withExecutionOrder.
@Test
public void recordChangeSets_withExecutionOrder() {
// Given
final int initialExecOrder = random.nextInt(10) + 1;
final int numChangeSets = random.nextInt(100) + 1;
final List<ChangeSet> changeSets = new ArrayList<>(numChangeSets);
for (int i = 0; i < numChangeSets; i++) {
changeSets.add(newChangeSet("id" + (i + 1)));
}
doNothing().when(schemaChangeLogDao).insertChangeLog(anyString(), any(SchemaChangeLog.class));
// When
List<SchemaChangeLog> schemaChangeLogs = schemaChangeLogService.recordChangeSets("namespace", initialExecOrder, changeSets);
// Then
MatcherAssert.assertThat(schemaChangeLogs.size(), equalTo(numChangeSets));
for (int i = 0; i < numChangeSets; i++) {
SchemaChangeLog schemaChangeLog = schemaChangeLogs.get(i);
ChangeSet changeSet = changeSets.get(i);
MatcherAssert.assertThat(schemaChangeLog.getId(), equalTo(changeSet.getId()));
int expectedExecOrder = initialExecOrder + i;
MatcherAssert.assertThat(schemaChangeLog.getExecOrder(), equalTo(expectedExecOrder));
}
}
Aggregations