Search in sources :

Example 1 with Audit

use of com.ctrip.framework.apollo.biz.entity.Audit 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());
}
Also used : App(com.ctrip.framework.apollo.common.entity.App) Audit(com.ctrip.framework.apollo.biz.entity.Audit) Cluster(com.ctrip.framework.apollo.biz.entity.Cluster) Date(java.util.Date) Namespace(com.ctrip.framework.apollo.biz.entity.Namespace) Test(org.junit.Test) AbstractIntegrationTest(com.ctrip.framework.apollo.biz.AbstractIntegrationTest)

Example 2 with Audit

use of com.ctrip.framework.apollo.biz.entity.Audit in project apollo by ctripcorp.

the class AuditService method audit.

@Transactional
void audit(String entityName, Long entityId, Audit.OP op, String owner) {
    Audit audit = new Audit();
    audit.setEntityName(entityName);
    audit.setEntityId(entityId);
    audit.setOpName(op.name());
    audit.setDataChangeCreatedBy(owner);
    auditRepository.save(audit);
}
Also used : Audit(com.ctrip.framework.apollo.biz.entity.Audit) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Audit (com.ctrip.framework.apollo.biz.entity.Audit)2 AbstractIntegrationTest (com.ctrip.framework.apollo.biz.AbstractIntegrationTest)1 Cluster (com.ctrip.framework.apollo.biz.entity.Cluster)1 Namespace (com.ctrip.framework.apollo.biz.entity.Namespace)1 App (com.ctrip.framework.apollo.common.entity.App)1 Date (java.util.Date)1 Test (org.junit.Test)1 Transactional (org.springframework.transaction.annotation.Transactional)1