Search in sources :

Example 26 with ItemChangeSets

use of com.ctrip.framework.apollo.common.dto.ItemChangeSets in project apollo by ctripcorp.

the class PropertyResolverTest method testUpdateCommentItem.

@Test
public void testUpdateCommentItem() {
    ItemChangeSets changeSets = resolver.resolve(1, "#ww\n" + "a=b\n" + "\n" + "b=c", mockBaseItemWith2Key1Comment1Blank());
    Assert.assertEquals(1, changeSets.getDeleteItems().size());
    Assert.assertEquals(0, changeSets.getUpdateItems().size());
    Assert.assertEquals(1, changeSets.getCreateItems().size());
}
Also used : ItemChangeSets(com.ctrip.framework.apollo.common.dto.ItemChangeSets) Test(org.junit.Test) AbstractUnitTest(com.ctrip.framework.apollo.portal.AbstractUnitTest)

Example 27 with ItemChangeSets

use of com.ctrip.framework.apollo.common.dto.ItemChangeSets in project apollo by ctripcorp.

the class PropertyResolverTest method testChangeItemNumLine.

@Test
public void testChangeItemNumLine() {
    ItemChangeSets changeSets = resolver.resolve(1, "b=c\nc=d\na=b", mockBaseItemHas3Key());
    Assert.assertEquals(3, changeSets.getUpdateItems().size());
}
Also used : ItemChangeSets(com.ctrip.framework.apollo.common.dto.ItemChangeSets) Test(org.junit.Test) AbstractUnitTest(com.ctrip.framework.apollo.portal.AbstractUnitTest)

Example 28 with ItemChangeSets

use of com.ctrip.framework.apollo.common.dto.ItemChangeSets in project apollo by ctripcorp.

the class PropertyResolverTest method testUpdateItem.

@Test
public void testUpdateItem() {
    ItemChangeSets changeSets = resolver.resolve(1, "a=d", mockBaseItemHas3Key());
    List<ItemDTO> updateItems = changeSets.getUpdateItems();
    Assert.assertEquals(1, updateItems.size());
    Assert.assertEquals("d", updateItems.get(0).getValue());
}
Also used : ItemChangeSets(com.ctrip.framework.apollo.common.dto.ItemChangeSets) ItemDTO(com.ctrip.framework.apollo.common.dto.ItemDTO) Test(org.junit.Test) AbstractUnitTest(com.ctrip.framework.apollo.portal.AbstractUnitTest)

Aggregations

ItemChangeSets (com.ctrip.framework.apollo.common.dto.ItemChangeSets)28 Test (org.junit.Test)18 AbstractUnitTest (com.ctrip.framework.apollo.portal.AbstractUnitTest)15 ItemDTO (com.ctrip.framework.apollo.common.dto.ItemDTO)14 NamespaceDTO (com.ctrip.framework.apollo.common.dto.NamespaceDTO)8 BadRequestException (com.ctrip.framework.apollo.common.exception.BadRequestException)5 ItemDiffs (com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs)5 NamespaceIdentifier (com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier)5 Item (com.ctrip.framework.apollo.biz.entity.Item)3 AppDTO (com.ctrip.framework.apollo.common.dto.AppDTO)3 ClusterDTO (com.ctrip.framework.apollo.common.dto.ClusterDTO)3 UserInfo (com.ctrip.framework.apollo.portal.entity.bo.UserInfo)3 TestRestTemplate (org.springframework.boot.test.web.client.TestRestTemplate)3 Sql (org.springframework.test.context.jdbc.Sql)3 RestTemplate (org.springframework.web.client.RestTemplate)3 ReleaseDTO (com.ctrip.framework.apollo.common.dto.ReleaseDTO)2 Env (com.ctrip.framework.apollo.portal.environment.Env)2 HashMap (java.util.HashMap)2 ConfigTextResolver (com.ctrip.framework.apollo.portal.component.txtresolver.ConfigTextResolver)1 NamespaceBO (com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO)1