Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.80 KB | None | 0 0
  1. @Test
  2.     public void createProfileNumeralName() {
  3.         appProfileServiceForDelete = "0123456789";
  4.         HashMap<Integer, String> appProfilesData = new HashMap<>();
  5.         final List<AppProfileService> listProfiles = listProfileService(getAuthToken());
  6.  
  7.         for (AppProfileService app : listProfiles) {
  8.             appProfilesData.put(app.getId(), app.getName());
  9.         }
  10.  
  11.         if (appProfilesData.containsValue(appProfileServiceForDelete)) {
  12.             deleteProfileService(searchKeyMap(appProfilesData, appProfileServiceForDelete), getAuthToken());
  13.         }
  14.  
  15.         ResponseEntity<String> numericalProfileName = createProfileService(getAuthToken(), appProfileServiceForDelete);
  16.         Assert.assertEquals(numericalProfileName.getStatusCode(), HttpStatus.OK);
  17.  
  18.         HashMap<Integer, String> appProfilesDataAfterDelete = new HashMap<>();
  19.         final List<AppProfileService> listProfilesAfterDelete = listProfileService(getAuthToken());
  20.         for (AppProfileService app : listProfilesAfterDelete) {
  21.             appProfilesDataAfterDelete.put(app.getId(), app.getName());
  22.         }
  23.         System.out.println(appProfilesDataAfterDelete);
  24.  
  25.         if (listProfiles.isEmpty() || !appProfilesData.containsValue(appProfileServiceForDelete)) {
  26.             deleteProfileService(searchKeyMap(appProfilesDataAfterDelete, appProfileServiceForDelete), getAuthToken());
  27.         }
  28.     }
  29.  
  30.     public static Integer searchKeyMap(HashMap<Integer, String> map, String value) {
  31.         Iterator it = map.entrySet().iterator();
  32.         Integer key = null;
  33.         while (it.hasNext()) {
  34.             Map.Entry pair = (Map.Entry)it.next();
  35.             if (pair.getValue() == value) {
  36.                 key = (Integer) pair.getKey();
  37.             }
  38.         }
  39.         it.remove();
  40.         return key;
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement