Skip to content

Commit

Permalink
KAA-977: Remove deprecated REST API call methods that are based on Ap…
Browse files Browse the repository at this point in the history
…plicationId instead of Application Tokens (#752)

KAA-977: Ignore applicationId field
  • Loading branch information
sashadidukh authored and ashvayka committed Jun 15, 2016
1 parent 6d342fa commit b92a40d
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 1,193 deletions.

Large diffs are not rendered by default.

Expand Up @@ -16,6 +16,8 @@

package org.kaaproject.kaa.common.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;

import java.io.Serializable;
import java.util.Arrays;

Expand All @@ -28,6 +30,7 @@ public class EndpointProfileBodyDto implements Serializable {
private String serverSideProfile;
private int clientSideProfileVersion;
private int serverSideProfileVersion;
@JsonIgnore
private String appId;

public EndpointProfileBodyDto() {}
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -1185,23 +1185,23 @@ protected ApplicationEventFamilyMapDto createApplicationEventFamilyMap() throws
/**
* Creates the application event family map.
*
* @param applicationId the application id
* @param applicationToken the application token
* @param ecfId the ecf id
* @param version the version
* @return the application event family map dto
* @throws Exception the exception
*/
protected ApplicationEventFamilyMapDto createApplicationEventFamilyMap(String applicationId, String ecfId, int version) throws Exception {
protected ApplicationEventFamilyMapDto createApplicationEventFamilyMap(String applicationToken, String ecfId, int version) throws Exception {
ApplicationEventFamilyMapDto applicationEventFamilyMap = new ApplicationEventFamilyMapDto();
String tenantId = null;
if (strIsEmpty(applicationId)) {
if (strIsEmpty(applicationToken)) {
ApplicationDto application = createApplication(tenantAdminDto);
tenantId = application.getTenantId();
applicationEventFamilyMap.setApplicationId(application.getId());
}
else {
applicationEventFamilyMap.setApplicationId(applicationId);
ApplicationDto application = client.getApplication(applicationId);
ApplicationDto application = client.getApplicationByApplicationToken(applicationToken);
applicationEventFamilyMap.setApplicationId(application.getId());
tenantId = application.getTenantId();
}
EventClassFamilyDto eventClassFamily = null;
Expand Down Expand Up @@ -1252,7 +1252,7 @@ protected String ctlRandomFieldType() {
}

protected CTLSchemaDto createCTLSchema(String name, String namespace, int version,
String tenantId, String applicationId, Set<FqnVersion> dependencies,
String tenantId, String applicationToken, Set<FqnVersion> dependencies,
Map<String, String> fields) throws Exception {

LOG.debug("Generating CTL schema...");
Expand Down Expand Up @@ -1289,7 +1289,7 @@ protected CTLSchemaDto createCTLSchema(String name, String namespace, int versio

LOG.debug("CTL schema generated: " + body);

return client.saveCTLSchema(body.toString(), tenantId, applicationId);
return client.saveCTLSchemaWithAppToken(body.toString(), tenantId, applicationToken);
}

/**
Expand Down
Expand Up @@ -60,32 +60,6 @@ public void testGetApplicationEventFamilyMap() throws Exception {
Assert.assertEquals(applicationEventFamilyMap, storedApplicationEventFamilyMap);
}

/**
* Test get application event family maps by application id.
*
* @throws Exception the exception
*/
@Test
public void testGetApplicationEventFamilyMapsByApplicationId() throws Exception {
List<ApplicationEventFamilyMapDto> applicationEventFamilyMaps = new ArrayList<ApplicationEventFamilyMapDto>(10);
ApplicationDto application = createApplication(tenantAdminDto);
EventClassFamilyDto eventClassFamily = createEventClassFamily(application.getTenantId());
for (int i=0;i<10;i++) {
ApplicationEventFamilyMapDto applicationEventFamilyMap = createApplicationEventFamilyMap(application.getId(), eventClassFamily.getId(), (i+1));
applicationEventFamilyMaps.add(applicationEventFamilyMap);
}

Collections.sort(applicationEventFamilyMaps, new IdComparator());

loginTenantDeveloper(tenantDeveloperUser);

List<ApplicationEventFamilyMapDto> storedApplicationEventFamilyMaps = client.getApplicationEventFamilyMapsByApplicationId(application.getId());

Collections.sort(storedApplicationEventFamilyMaps, new IdComparator());

Assert.assertEquals(applicationEventFamilyMaps, storedApplicationEventFamilyMaps);
}

/**
* Test get application event family maps by application token.
*
Expand All @@ -97,7 +71,8 @@ public void testGetApplicationEventFamilyMapsByApplicationToken() throws Excepti
ApplicationDto application = createApplication(tenantAdminDto);
EventClassFamilyDto eventClassFamily = createEventClassFamily(application.getTenantId());
for (int i=0;i<10;i++) {
ApplicationEventFamilyMapDto applicationEventFamilyMap = createApplicationEventFamilyMap(application.getId(), eventClassFamily.getId(), (i+1));
ApplicationEventFamilyMapDto applicationEventFamilyMap = createApplicationEventFamilyMap(
application.getApplicationToken(), eventClassFamily.getId(), (i+1));
applicationEventFamilyMaps.add(applicationEventFamilyMap);
}

Expand Down Expand Up @@ -129,35 +104,6 @@ public void executeRestCall() throws Exception {
});
}

/**
* Test get vacant event class families by application id.
*
* @throws Exception the exception
*/
@Test
public void testGetVacantEventClassFamiliesByApplicationId() throws Exception {
ApplicationDto application = createApplication(tenantAdminDto);
EventClassFamilyDto eventClassFamily = createEventClassFamily(application.getTenantId());
createApplicationEventFamilyMap(application.getId(), eventClassFamily.getId(), 1);

loginTenantDeveloper(tenantDeveloperUser);
List<EcfInfoDto> vacantEcfs = client.getVacantEventClassFamiliesByApplicationId(application.getId());
Assert.assertNotNull(vacantEcfs);
Assert.assertEquals(0, vacantEcfs.size());

loginTenantAdmin(tenantAdminUser);
client.addEventClassFamilySchema(eventClassFamily.getId(), TEST_EVENT_CLASS_FAMILY_SCHEMA);

loginTenantDeveloper(tenantDeveloperUser);
vacantEcfs = client.getVacantEventClassFamiliesByApplicationId(application.getId());
Assert.assertNotNull(vacantEcfs);
Assert.assertEquals(1, vacantEcfs.size());
Assert.assertNotNull(vacantEcfs.get(0));
Assert.assertEquals(eventClassFamily.getId(), vacantEcfs.get(0).getEcfId());
Assert.assertEquals(eventClassFamily.getName(), vacantEcfs.get(0).getEcfName());
Assert.assertEquals(2, vacantEcfs.get(0).getVersion());
}

/**
* Test get vacant event class families by application token.
*
Expand All @@ -167,7 +113,7 @@ public void testGetVacantEventClassFamiliesByApplicationId() throws Exception {
public void testGetVacantEventClassFamiliesByApplicationToken() throws Exception {
ApplicationDto application = createApplication(tenantAdminDto);
EventClassFamilyDto eventClassFamily = createEventClassFamily(application.getTenantId());
createApplicationEventFamilyMap(application.getId(), eventClassFamily.getId(), 1);
createApplicationEventFamilyMap(application.getApplicationToken(), eventClassFamily.getId(), 1);

loginTenantDeveloper(tenantDeveloperUser);
List<EcfInfoDto> vacantEcfs = client.getVacantEventClassFamiliesByApplicationToken(application.getApplicationToken());
Expand All @@ -187,28 +133,6 @@ public void testGetVacantEventClassFamiliesByApplicationToken() throws Exception
Assert.assertEquals(2, vacantEcfs.get(0).getVersion());
}

/**
* Test get event class families by application id.
*
* @throws Exception the exception
*/
@Test
public void testGetEventClassFamiliesByApplicationId() throws Exception {
ApplicationDto application = createApplication(tenantAdminDto);
EventClassFamilyDto eventClassFamily = createEventClassFamily(application.getTenantId());
createApplicationEventFamilyMap(application.getId(), eventClassFamily.getId(), 1);

loginTenantDeveloper(tenantDeveloperUser);

List<AefMapInfoDto> applicationEcfs = client.getEventClassFamiliesByApplicationId(application.getId());
Assert.assertNotNull(applicationEcfs);
Assert.assertEquals(1, applicationEcfs.size());
Assert.assertNotNull(applicationEcfs.get(0));
Assert.assertEquals(eventClassFamily.getId(), applicationEcfs.get(0).getEcfId());
Assert.assertEquals(eventClassFamily.getName(), applicationEcfs.get(0).getEcfName());
Assert.assertEquals(1, applicationEcfs.get(0).getVersion());
}

/**
* Test get event class families by application token.
*
Expand All @@ -218,7 +142,7 @@ public void testGetEventClassFamiliesByApplicationId() throws Exception {
public void testGetEventClassFamiliesByApplicationToken() throws Exception {
ApplicationDto application = createApplication(tenantAdminDto);
EventClassFamilyDto eventClassFamily = createEventClassFamily(application.getTenantId());
createApplicationEventFamilyMap(application.getId(), eventClassFamily.getId(), 1);
createApplicationEventFamilyMap(application.getApplicationToken(), eventClassFamily.getId(), 1);

loginTenantDeveloper(tenantDeveloperUser);

Expand Down
Expand Up @@ -58,21 +58,6 @@ public void testCreateApplication() throws Exception {
public void testGetApplication() throws Exception {
ApplicationDto application = createApplication();

ApplicationDto storedApplication = client.getApplication(application.getId());

Assert.assertNotNull(storedApplication);
assertApplicationsEquals(application, storedApplication);
}

/**
* Test get application by app token.
*
* @throws Exception the exception
*/
@Test
public void testGetApplicationByAppToken() throws Exception {
ApplicationDto application = createApplication();

ApplicationDto storedApplication = client.getApplicationByApplicationToken(application.getApplicationToken());

Assert.assertNotNull(storedApplication);
Expand Down Expand Up @@ -136,7 +121,7 @@ public void testDeleteApplication() throws Exception {
checkNotFound(new TestRestCall() {
@Override
public void executeRestCall() throws Exception {
client.getApplication(application.getId());
client.getApplicationByApplicationToken(application.getApplicationToken());
}
});
}
Expand Down

0 comments on commit b92a40d

Please sign in to comment.