@Before
 public void setup() {
   when(resource1.getName()).thenReturn("resource1");
   when(resource2.getName()).thenReturn("resource2");
   List<ResourceDTO> resources = new ArrayList<ResourceDTO>();
   resources.add(resource1);
   resources.add(resource2);
   when(resourceService.getResources(PROJECT_NAME, VERSION_NAME)).thenReturn(resources);
   Map<ResourceDTO, RatioCollection> ratioByResource = new HashMap<ResourceDTO, RatioCollection>();
   ratioByResource.put(resource1, ratioCollection1);
   ratioByResource.put(resource2, ratioCollection2);
   when(ratioCollection1.getTranslateRatio()).thenReturn(translateRatio1);
   when(ratioCollection1.getReviewRatio()).thenReturn(reviewRatio1);
   when(ratioCollection2.getTranslateRatio()).thenReturn(translateRatio2);
   when(ratioCollection2.getReviewRatio()).thenReturn(reviewRatio2);
   when(translationRatioService.getLocalizationRatioCollectionsByResourceMap(
           PROJECT_NAME, VERSION_NAME, LOCALE))
       .thenReturn(ratioByResource);
 }
Example #2
0
 /**
  * This method updates the PushNotificationSupportDTO's maps. For each language, if every source
  * was translated and reviewed, the value is set to true (done). It is called twice: before and
  * after the push
  *
  * @param pushNotificationSupportDTO
  * @param projectName
  * @param versionName
  * @param moment
  * @author vlstr
  */
 private void checkCurrentTranslationState(
     PushNotificationSupportDTO pushNotificationSupportDTO,
     String projectName,
     String versionName,
     String moment) {
   Map<Locale, RatioCollection> ratioMap =
       translationRatioService.getRatioCollectionsByLocaleMap(projectName, versionName);
   Map<Locale, Boolean> statusMap = new HashMap<Locale, Boolean>();
   for (Locale locale : ratioMap.keySet()) {
     if (((int) Math.floor(ratioMap.get(locale).getTranslateRatio().getPercentage())) == 100) {
       statusMap.put(locale, true);
     } else {
       statusMap.put(locale, false);
     }
   }
   if (moment.equals("before")) {
     pushNotificationSupportDTO.setIsTranslationDoneBeforePush(statusMap);
   }
   if (moment.equals("after")) {
     pushNotificationSupportDTO.setIsTranslationDoneAfterPush(statusMap);
   }
 }