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();
}
}
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;
}
Aggregations