Example #1
0
  @Test
  public void updateProfileServiceTest() throws IOException {
    byte[] profile = baseAvroConverter.encode(ENDPOINT_PROFILE);
    RegisterProfileRequest request =
        new RegisterProfileRequest(
            application.getApplicationToken(), ENDPOINT_KEY, sdkToken, profile);

    EndpointProfileDto oldDto = profileService.registerProfile(request);

    Assert.assertEquals(
        baseAvroConverter.encodeToJson(ENDPOINT_PROFILE),
        oldDto.getClientProfileBody().replaceAll(" ", ""));

    byte[] newProfile = newAvroConverter.encode(NEW_ENDPOINT_PROFILE);
    UpdateProfileRequest updateRequest =
        new UpdateProfileRequest(
            application.getApplicationToken(),
            EndpointObjectHash.fromSha1(ENDPOINT_KEY),
            null,
            newProfile,
            newSdkToken);
    EndpointProfileDto newDto = profileService.updateProfile(updateRequest);

    Assert.assertNotNull(newDto);
    Assert.assertNotNull(newDto.getId());
    Assert.assertEquals(oldDto.getId(), newDto.getId());
    Assert.assertEquals(
        newAvroConverter.encodeToJson(NEW_ENDPOINT_PROFILE),
        newDto.getClientProfileBody().replaceAll(" ", ""));
    Assert.assertTrue(
        Arrays.equals(EndpointObjectHash.fromSha1(newProfile).getData(), newDto.getProfileHash()));
  }
Example #2
0
 @Test
 public void registerProfileServiceTest() throws IOException {
   byte[] profile = baseAvroConverter.encode(ENDPOINT_PROFILE);
   RegisterProfileRequest request =
       new RegisterProfileRequest(
           application.getApplicationToken(), ENDPOINT_KEY, sdkToken, profile);
   EndpointProfileDto dto = profileService.registerProfile(request);
   Assert.assertNotNull(dto);
   Assert.assertNotNull(dto.getId());
   Assert.assertTrue(Arrays.equals(ENDPOINT_KEY, dto.getEndpointKey()));
   Assert.assertTrue(
       Arrays.equals(
           EndpointObjectHash.fromSha1(ENDPOINT_KEY).getData(), dto.getEndpointKeyHash()));
   Assert.assertEquals(
       baseAvroConverter.encodeToJson(ENDPOINT_PROFILE),
       dto.getClientProfileBody().replaceAll(" ", ""));
   Assert.assertTrue(
       Arrays.equals(EndpointObjectHash.fromSha1(profile).getData(), dto.getProfileHash()));
 }