use of com.ctrip.framework.apollo.common.dto.ItemChangeSets in project apollo by ctripcorp.
the class ItemService method compare.
public List<ItemDiffs> compare(List<NamespaceIdentifier> comparedNamespaces, List<ItemDTO> sourceItems) {
List<ItemDiffs> result = new LinkedList<>();
for (NamespaceIdentifier namespace : comparedNamespaces) {
ItemDiffs itemDiffs = new ItemDiffs(namespace);
try {
itemDiffs.setDiffs(parseChangeSets(namespace, sourceItems));
} catch (BadRequestException e) {
itemDiffs.setDiffs(new ItemChangeSets());
itemDiffs.setExtInfo("该集群下没有名为 " + namespace.getNamespaceName() + " 的namespace");
}
result.add(itemDiffs);
}
return result;
}
use of com.ctrip.framework.apollo.common.dto.ItemChangeSets in project apollo by ctripcorp.
the class PropertyResolverTest method testAddItemBeforeHasItem.
@Test
public void testAddItemBeforeHasItem() {
ItemChangeSets changeSets = resolver.resolve(1, "x=y\na=b\nb=c\nc=d", mockBaseItemHas3Key());
Assert.assertEquals("x", changeSets.getCreateItems().get(0).getKey());
Assert.assertEquals(1, changeSets.getCreateItems().size());
Assert.assertEquals(3, changeSets.getUpdateItems().size());
}
use of com.ctrip.framework.apollo.common.dto.ItemChangeSets in project apollo by ctripcorp.
the class PropertyResolverTest method testDeleteCommentItem.
@Test
public void testDeleteCommentItem() {
ItemChangeSets changeSets = resolver.resolve(1, "a=b\n\nb=c", mockBaseItemWith2Key1Comment1Blank());
Assert.assertEquals(2, changeSets.getDeleteItems().size());
Assert.assertEquals(2, changeSets.getUpdateItems().size());
Assert.assertEquals(1, changeSets.getCreateItems().size());
}
use of com.ctrip.framework.apollo.common.dto.ItemChangeSets in project apollo by ctripcorp.
the class PropertyResolverTest method testAllSituation.
@Test
public void testAllSituation() {
ItemChangeSets changeSets = resolver.resolve(1, "#ww\nd=e\nb=c\na=b\n\nq=w\n#eee", mockBaseItemWith2Key1Comment1Blank());
Assert.assertEquals(2, changeSets.getDeleteItems().size());
Assert.assertEquals(2, changeSets.getUpdateItems().size());
Assert.assertEquals(5, changeSets.getCreateItems().size());
}
use of com.ctrip.framework.apollo.common.dto.ItemChangeSets in project apollo by ctripcorp.
the class PropertyResolverTest method testAddItemBeforeNoItem.
@Test
public void testAddItemBeforeNoItem() {
ItemChangeSets changeSets = resolver.resolve(1, "a=b\nb=c", Collections.emptyList());
Assert.assertEquals(2, changeSets.getCreateItems().size());
}
Aggregations