use of com.ctrip.framework.apollo.common.entity.App in project apollo by ctripcorp.
the class AppControllerTest method testDelete.
@Test
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testDelete() {
AppDTO dto = generateSampleDTOData();
App app = BeanUtils.transfrom(App.class, dto);
app = appRepository.save(app);
restTemplate.delete("http://localhost:{port}/apps/{appId}?operator={operator}", port, app.getAppId(), "test");
App deletedApp = appRepository.findOne(app.getId());
Assert.assertNull(deletedApp);
}
use of com.ctrip.framework.apollo.common.entity.App in project apollo by ctripcorp.
the class AppControllerTest method testCreateTwice.
@Test
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testCreateTwice() {
AppDTO dto = generateSampleDTOData();
ResponseEntity<AppDTO> response = restTemplate.postForEntity(getBaseAppUrl(), dto, AppDTO.class);
AppDTO first = response.getBody();
Assert.assertEquals(HttpStatus.OK, response.getStatusCode());
Assert.assertEquals(dto.getAppId(), first.getAppId());
Assert.assertTrue(first.getId() > 0);
App savedApp = appRepository.findOne(first.getId());
Assert.assertEquals(dto.getAppId(), savedApp.getAppId());
Assert.assertNotNull(savedApp.getDataChangeCreatedTime());
try {
restTemplate.postForEntity(getBaseAppUrl(), dto, AppDTO.class);
} catch (HttpClientErrorException e) {
Assert.assertEquals(HttpStatus.BAD_REQUEST, e.getStatusCode());
}
}
use of com.ctrip.framework.apollo.common.entity.App in project apollo by ctripcorp.
the class AppControllerTest method testFind.
@Test
@Sql(scripts = "/controller/cleanup.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
public void testFind() {
AppDTO dto = generateSampleDTOData();
App app = BeanUtils.transfrom(App.class, dto);
app = appRepository.save(app);
AppDTO result = restTemplate.getForObject(getBaseAppUrl() + dto.getAppId(), AppDTO.class);
Assert.assertEquals(dto.getAppId(), result.getAppId());
Assert.assertEquals(dto.getName(), result.getName());
}
use of com.ctrip.framework.apollo.common.entity.App in project apollo by ctripcorp.
the class AppController method delete.
@RequestMapping(value = "/apps/{appId:.+}", method = RequestMethod.DELETE)
public void delete(@PathVariable("appId") String appId, @RequestParam String operator) {
App entity = appService.findOne(appId);
if (entity == null) {
throw new NotFoundException("app not found for appId " + appId);
}
appService.delete(entity.getId(), operator);
}
use of com.ctrip.framework.apollo.common.entity.App in project apollo by ctripcorp.
the class AdminServiceTest method testCreateNewApp.
@Test
public void testCreateNewApp() {
String appId = "someAppId";
App app = new App();
app.setAppId(appId);
app.setName("someAppName");
String owner = "someOwnerName";
app.setOwnerName(owner);
app.setOwnerEmail("someOwnerName@ctrip.com");
app.setDataChangeCreatedBy(owner);
app.setDataChangeLastModifiedBy(owner);
app.setDataChangeCreatedTime(new Date());
app = adminService.createNewApp(app);
Assert.assertEquals(appId, app.getAppId());
List<Cluster> clusters = clusterService.findParentClusters(app.getAppId());
Assert.assertEquals(1, clusters.size());
Assert.assertEquals(ConfigConsts.CLUSTER_NAME_DEFAULT, clusters.get(0).getName());
List<Namespace> namespaces = namespaceService.findNamespaces(appId, clusters.get(0).getName());
Assert.assertEquals(1, namespaces.size());
Assert.assertEquals(ConfigConsts.NAMESPACE_APPLICATION, namespaces.get(0).getNamespaceName());
List<Audit> audits = auditService.findByOwner(owner);
Assert.assertEquals(4, audits.size());
}
Aggregations