use of com.ctrip.framework.apollo.common.dto.ItemDTO in project apollo by ctripcorp.
the class ReleaseControllerTest method testReleaseBuild.
@Test
@Sql(scripts = "/controller/test-release.sql", executionPhase = ExecutionPhase.BEFORE_TEST_METHOD)
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testReleaseBuild() {
String appId = "someAppId";
AppDTO app = restTemplate.getForObject("http://localhost:" + port + "/apps/" + appId, AppDTO.class);
ClusterDTO cluster = restTemplate.getForObject("http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/default", ClusterDTO.class);
NamespaceDTO namespace = restTemplate.getForObject("http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName() + "/namespaces/application", NamespaceDTO.class);
Assert.assertEquals("someAppId", app.getAppId());
Assert.assertEquals("default", cluster.getName());
Assert.assertEquals("application", namespace.getNamespaceName());
ItemDTO[] items = restTemplate.getForObject("http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/items", ItemDTO[].class);
Assert.assertEquals(3, items.length);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> parameters = new LinkedMultiValueMap<>();
parameters.add("name", "someReleaseName");
parameters.add("comment", "someComment");
parameters.add("operator", "test");
HttpEntity<MultiValueMap<String, String>> entity = new HttpEntity<>(parameters, headers);
ResponseEntity<ReleaseDTO> response = restTemplate.postForEntity("http://localhost:" + port + "/apps/" + app.getAppId() + "/clusters/" + cluster.getName() + "/namespaces/" + namespace.getNamespaceName() + "/releases", entity, ReleaseDTO.class);
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
ReleaseDTO release = response.getBody();
Assert.assertEquals("someReleaseName", release.getName());
Assert.assertEquals("someComment", release.getComment());
Assert.assertEquals("someAppId", release.getAppId());
Assert.assertEquals("default", release.getClusterName());
Assert.assertEquals("application", release.getNamespaceName());
Map<String, String> configurations = new HashMap<>();
configurations.put("k1", "v1");
configurations.put("k2", "v2");
configurations.put("k3", "v3");
Assert.assertEquals(GSON.toJson(configurations), release.getConfigurations());
}
use of com.ctrip.framework.apollo.common.dto.ItemDTO in project apollo by ctripcorp.
the class ConfigsExportServiceTest method genItem.
private ItemBO genItem(String key, String value) {
ItemBO itemBO = new ItemBO();
ItemDTO itemDTO = new ItemDTO();
itemDTO.setKey(key);
itemDTO.setValue(value);
itemBO.setItem(itemDTO);
return itemBO;
}
use of com.ctrip.framework.apollo.common.dto.ItemDTO in project apollo by ctripcorp.
the class NamespaceBOUtils method convertNonProperties2configFileContent.
/**
* namespace must not be {@link ConfigFileFormat#Properties}. the content of namespace in item's value which item's
* key is {@link ConfigConsts#CONFIG_FILE_CONTENT_KEY}.
*
* @param namespaceBO namespace
* @return content of non-properties's namespace
*/
static String convertNonProperties2configFileContent(NamespaceBO namespaceBO) {
List<ItemBO> itemBOS = namespaceBO.getItems();
for (ItemBO itemBO : itemBOS) {
String key = itemBO.getItem().getKey();
// special namespace format(not properties)
if (ConfigConsts.CONFIG_FILE_CONTENT_KEY.equals(key)) {
ItemDTO dto = itemBO.getItem();
dto.setId(0);
dto.setNamespaceId(0);
return GSON.toJson(Lists.newArrayList(dto));
}
}
return "";
}
use of com.ctrip.framework.apollo.common.dto.ItemDTO in project apollo by ctripcorp.
the class PropertyResolverTest method mockBaseItemHas3Key.
/**
* a=b b=c c=d
*/
private List<ItemDTO> mockBaseItemHas3Key() {
ItemDTO item1 = new ItemDTO("a", "b", "", 1);
ItemDTO item2 = new ItemDTO("b", "c", "", 2);
ItemDTO item3 = new ItemDTO("c", "d", "", 3);
return Arrays.asList(item1, item2, item3);
}
use of com.ctrip.framework.apollo.common.dto.ItemDTO in project apollo by ctripcorp.
the class PropertyResolverTest method mockBaseItemWith2Key1Comment1Blank.
/**
* #qqqq
* a=b
*
* b=c
*/
private List<ItemDTO> mockBaseItemWith2Key1Comment1Blank() {
ItemDTO i1 = new ItemDTO("", "", "#qqqq", 1);
ItemDTO i2 = new ItemDTO("a", "b", "", 2);
ItemDTO i3 = new ItemDTO("", "", "", 3);
ItemDTO i4 = new ItemDTO("b", "c", "", 4);
i4.setLineNum(4);
return Arrays.asList(i1, i2, i3, i4);
}
Aggregations