Search in sources :

Example 1 with NamespaceTextModel

use of com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel in project apollo by ctripcorp.

the class ConfigServiceTest method testUpdateConfigByText.

@Test
public void testUpdateConfigByText() {
    String appId = "6666";
    String clusterName = "default";
    String namespaceName = "application";
    long someNamespaceId = 123L;
    NamespaceTextModel model = new NamespaceTextModel();
    model.setEnv("DEV");
    model.setNamespaceName(namespaceName);
    model.setClusterName(clusterName);
    model.setAppId(appId);
    model.setConfigText("a=b\nb=c\nc=d\nd=e");
    model.setFormat(ConfigFileFormat.Properties.getValue());
    List<ItemDTO> itemDTOs = mockBaseItemHas3Key();
    ItemChangeSets changeSets = new ItemChangeSets();
    changeSets.addCreateItem(new ItemDTO("d", "c", "", 4));
    NamespaceDTO someNamespaceDto = mock(NamespaceDTO.class);
    when(someNamespaceDto.getId()).thenReturn(someNamespaceId);
    when(namespaceAPI.loadNamespace(appId, model.getEnv(), clusterName, namespaceName)).thenReturn(someNamespaceDto);
    when(itemAPI.findItems(appId, Env.DEV, clusterName, namespaceName)).thenReturn(itemDTOs);
    when(resolver.resolve(someNamespaceId, model.getConfigText(), itemDTOs)).thenReturn(changeSets);
    UserInfo userInfo = new UserInfo();
    userInfo.setUserId("test");
    when(userInfoHolder.getUser()).thenReturn(userInfo);
    try {
        configService.updateConfigItemByText(model);
    } catch (Exception e) {
        Assert.fail();
    }
}
Also used : NamespaceDTO(com.ctrip.framework.apollo.common.dto.NamespaceDTO) NamespaceTextModel(com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel) ItemDTO(com.ctrip.framework.apollo.common.dto.ItemDTO) ItemChangeSets(com.ctrip.framework.apollo.common.dto.ItemChangeSets) UserInfo(com.ctrip.framework.apollo.portal.entity.bo.UserInfo) Test(org.junit.Test) AbstractUnitTest(com.ctrip.framework.apollo.portal.AbstractUnitTest)

Example 2 with NamespaceTextModel

use of com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel in project apollo by ctripcorp.

the class ItemControllerTest method assemble.

private NamespaceTextModel assemble(String format, String content) {
    NamespaceTextModel model = new NamespaceTextModel();
    model.setFormat(format);
    model.setConfigText(content);
    return model;
}
Also used : NamespaceTextModel(com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel)

Aggregations

NamespaceTextModel (com.ctrip.framework.apollo.portal.entity.model.NamespaceTextModel)2 ItemChangeSets (com.ctrip.framework.apollo.common.dto.ItemChangeSets)1 ItemDTO (com.ctrip.framework.apollo.common.dto.ItemDTO)1 NamespaceDTO (com.ctrip.framework.apollo.common.dto.NamespaceDTO)1 AbstractUnitTest (com.ctrip.framework.apollo.portal.AbstractUnitTest)1 UserInfo (com.ctrip.framework.apollo.portal.entity.bo.UserInfo)1 Test (org.junit.Test)1