test_class.declarator: intFiled = "int"
test_class.modifier: private final
test_class.original_string: private final String intFiled = "int";
test_class.type: String
test_class.var_name: intFiled
test_class.declarator: stringFiled = "str"
test_class.modifier: private final
test_class.original_string: private final String stringFiled = "str";
test_class.type: String
test_class.var_name: stringFiled
test_class.declarator: miscUtils
test_class.modifier: private
test_class.original_string: private MiscUtils miscUtils;
test_class.type: MiscUtils
test_class.var_name: miscUtils
test_class.file: BackEnd/Core/sailfish-core/src/test/java/com/exactpro/sf/actions/TestMiscUtils.java
test_class.identifier: TestMiscUtils
test_class.superclass: extends AbstractTest
test_case.body: @Test
      public void testIMessageCheckCount() throws Exception {
          IMessage empty = DefaultMessageFactory.getFactory().createMessage("name", "namespace");
          IMessage fullItem = empty.cloneMessage();
          fullItem.addField(intFiled, 1);
          IMessage partItem = fullItem.cloneMessage();
          fullItem.addField(stringFiled, "str");
  
          int count = 2;
          Collection<IMessage> msgCollection = Collections.nCopies(count, fullItem);
  
          Assert.assertTrue(miscUtils.checkCount(msgCollection, fullItem, count));
          Assert.assertTrue(miscUtils.checkCount(msgCollection, partItem, count));
          Assert.assertTrue(miscUtils.checkCount(msgCollection, empty, 0));
          Assert.assertFalse(miscUtils.checkCount(msgCollection, fullItem, 0));
          Assert.assertFalse(miscUtils.checkCount(msgCollection, partItem, 0));
          Assert.assertFalse(miscUtils.checkCount(msgCollection, empty, count));
  
          IMessage knownBugItem = empty.cloneMessage();
          knownBugItem.addField(intFiled,
                  StaticUtil.filter(0, null,
                          "um.call(SailfishURI.parse(\"BugsUtils.Expected\"), 2).Bug(\"int bug\", 1 )",
                          "um", SFLocalContext.getDefault().getUtilityManager()));
  
          FieldKnownBugException fieldKnownBugException = null;
          try {
              miscUtils.checkCount(msgCollection, knownBugItem, count);
          } catch (FieldKnownBugException e) {
              fieldKnownBugException = e;
          }
          Assert.assertEquals(1, fieldKnownBugException.getActualDescriptions().size());
          String subject = fieldKnownBugException.getActualDescriptions().toString();
          Assert.assertThat(subject, subject, containsString("int bug"));
          Assert.assertThat(subject, subject, not(containsString("string bug")));
  
          knownBugItem.addField(stringFiled,
                  StaticUtil.filter(0, null,
                          "um.call(SailfishURI.parse(\"BugsUtils.Expected\"), \"str2\").Bug(\"string bug\", \"str\" )",
                          "um", SFLocalContext.getDefault().getUtilityManager()));
          try {
              miscUtils.checkCount(msgCollection, knownBugItem, count);
          } catch (FieldKnownBugException e) {
              fieldKnownBugException = e;
          }
          
          Assert.assertEquals(1, fieldKnownBugException.getActualDescriptions().size());
          subject = fieldKnownBugException.getActualDescriptions().toString();
          Assert.assertThat(subject, subject, containsString("int bug"));
          Assert.assertThat(subject, subject, containsString("string bug"));
      }
test_case.class_method_signature: TestMiscUtils.testIMessageCheckCount()
test_case.full_signature: @Test public void testIMessageCheckCount()
test_case.identifier: testIMessageCheckCount
test_case.invocations: createMessage getFactory cloneMessage addField cloneMessage addField nCopies assertTrue checkCount assertTrue checkCount assertTrue checkCount assertFalse checkCount assertFalse checkCount assertFalse checkCount cloneMessage addField filter getUtilityManager getDefault checkCount assertEquals size getActualDescriptions toString getActualDescriptions assertThat containsString assertThat not containsString addField filter getUtilityManager getDefault checkCount assertEquals size getActualDescriptions toString getActualDescriptions assertThat containsString assertThat containsString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testIMessageCheckCount()
focal_class.file: BackEnd/Core/sailfish-core/src/main/java/com/exactpro/sf/actions/MiscUtils.java
focal_class.identifier: MiscUtils
focal_class.class_method_signature: MiscUtils.GetRandomString(String ... arr)
focal_class.full_signature: @Description("Returns a random element from an array of strings.<br/>" + "<b>arr</b> - array of strings.<br/>" + "Example:<br/>" + "#{GetRandomString(\"A\", \"B\", \"C\")}") @UtilityMethod public String GetRandomString(String ... arr)
focal_class.identifier: GetRandomString
focal_class.modifiers: @Description("Returns a random element from an array of strings.<br/>" + "<b>arr</b> - array of strings.<br/>" + "Example:<br/>" + "#{GetRandomString(\"A\", \"B\", \"C\")}") @UtilityMethod public
focal_class.parameters: (String ... arr)
focal_class.return: String
focal_class.signature: String GetRandomString(String ... arr)
focal_class.class_method_signature: MiscUtils.GetRandomString(int length)
focal_class.full_signature: @Description("Returns a string with random printable ASCII characters.<br/>" + "<b>length</b> - the length of the result string.<br/>" + "Example:<br/>" + "#{GetRandomString(23)}") @UtilityMethod public String GetRandomString(int length)
focal_class.identifier: GetRandomString
focal_class.modifiers: @Description("Returns a string with random printable ASCII characters.<br/>" + "<b>length</b> - the length of the result string.<br/>" + "Example:<br/>" + "#{GetRandomString(23)}") @UtilityMethod public
focal_class.parameters: (int length)
focal_class.return: String
focal_class.signature: String GetRandomString(int length)
focal_class.class_method_signature: MiscUtils.GetRandomInt(int ... arr)
focal_class.full_signature: @Description("Returns a random element from an array of integers.<br/>" + "<b>arr</b> - array of integers.<br/>" + "Example:<br/>" + "#{GetRandomInt(1, 2, 3)}") @UtilityMethod public int GetRandomInt(int ... arr)
focal_class.identifier: GetRandomInt
focal_class.modifiers: @Description("Returns a random element from an array of integers.<br/>" + "<b>arr</b> - array of integers.<br/>" + "Example:<br/>" + "#{GetRandomInt(1, 2, 3)}") @UtilityMethod public
focal_class.parameters: (int ... arr)
focal_class.return: int
focal_class.signature: int GetRandomInt(int ... arr)
focal_class.class_method_signature: MiscUtils.GetRandomLong(long ... arr)
focal_class.full_signature: @Description("Returns a random element from an array of long." + "<b>arr</b> - array of long.<br/>" + "Example:<br/>" + "#{GetRandomLong(1, 2, 3)}") @UtilityMethod public long GetRandomLong(long ... arr)
focal_class.identifier: GetRandomLong
focal_class.modifiers: @Description("Returns a random element from an array of long." + "<b>arr</b> - array of long.<br/>" + "Example:<br/>" + "#{GetRandomLong(1, 2, 3)}") @UtilityMethod public
focal_class.parameters: (long ... arr)
focal_class.return: long
focal_class.signature: long GetRandomLong(long ... arr)
focal_class.class_method_signature: MiscUtils.GenerateID()
focal_class.full_signature: @Description("Generates a unique string ID like 7e688747-7aa6-4304-b7a0-55d2a18ec91a." + "Example:<br/>" + "#{GenerateID()}") @UtilityMethod public String GenerateID()
focal_class.identifier: GenerateID
focal_class.modifiers: @Description("Generates a unique string ID like 7e688747-7aa6-4304-b7a0-55d2a18ec91a." + "Example:<br/>" + "#{GenerateID()}") @UtilityMethod public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String GenerateID()
focal_class.class_method_signature: MiscUtils.concat(Object... values)
focal_class.full_signature: @UtilityMethod @Description("Concatenates the string representations of the provided values into a single string.<br/>" + "<b>values</b> - string values for concatenating<br/>" + "Example:<br/> " + "#{concat(\"Text\", ' ', \"example\")} returns \"Text example\"") public String concat(Object... values)
focal_class.identifier: concat
focal_class.modifiers: @UtilityMethod @Description("Concatenates the string representations of the provided values into a single string.<br/>" + "<b>values</b> - string values for concatenating<br/>" + "Example:<br/> " + "#{concat(\"Text\", ' ', \"example\")} returns \"Text example\"") public
focal_class.parameters: (Object... values)
focal_class.return: String
focal_class.signature: String concat(Object... values)
focal_class.class_method_signature: MiscUtils.format(String format, Object... args)
focal_class.full_signature: @UtilityMethod @Description("Creates a formatted string using the provided format string and arguments.<br/>" + "<b>format</b> - provided format string.<br/>" + "<b>args</b> - values for formatting.<br/>" + "Example:<br/>" + "#{format(\"{} example{}\", \"Text\", '!')} returns \"Text example!\"") public String format(String format, Object... args)
focal_class.identifier: format
focal_class.modifiers: @UtilityMethod @Description("Creates a formatted string using the provided format string and arguments.<br/>" + "<b>format</b> - provided format string.<br/>" + "<b>args</b> - values for formatting.<br/>" + "Example:<br/>" + "#{format(\"{} example{}\", \"Text\", '!')} returns \"Text example!\"") public
focal_class.parameters: (String format, Object... args)
focal_class.return: String
focal_class.signature: String format(String format, Object... args)
focal_class.class_method_signature: MiscUtils.getSize(Collection<?> collection)
focal_class.full_signature: @UtilityMethod @Description("Returns the number of elements in this collection<br/>" + "<b>collection</b> - messages for size calculation<br/>" + "Considering the above said, the final syntax is:<br/>" + "#{getSize(collection)}") public int getSize(Collection<?> collection)
focal_class.identifier: getSize
focal_class.modifiers: @UtilityMethod @Description("Returns the number of elements in this collection<br/>" + "<b>collection</b> - messages for size calculation<br/>" + "Considering the above said, the final syntax is:<br/>" + "#{getSize(collection)}") public
focal_class.parameters: (Collection<?> collection)
focal_class.return: int
focal_class.signature: int getSize(Collection<?> collection)
focal_class.class_method_signature: MiscUtils.getSize(Collection<?> collection, Object filter)
focal_class.full_signature: @UtilityMethod @Description("Returns the number of messages in this collection in accordance with the filter<br/>" + "<b>collection</b> - messages for checking.<br/>" + "<b>filter</b> - filter message.<br/>" + "Considering the above said, the final syntax is:<br/>" + "#{getSize(collection, filter)}") public int getSize(Collection<?> collection, Object filter)
focal_class.identifier: getSize
focal_class.modifiers: @UtilityMethod @Description("Returns the number of messages in this collection in accordance with the filter<br/>" + "<b>collection</b> - messages for checking.<br/>" + "<b>filter</b> - filter message.<br/>" + "Considering the above said, the final syntax is:<br/>" + "#{getSize(collection, filter)}") public
focal_class.parameters: (Collection<?> collection, Object filter)
focal_class.return: int
focal_class.signature: int getSize(Collection<?> collection, Object filter)
focal_class.class_method_signature: MiscUtils.checkCount(Collection<?> collection, Object filter, int expected)
focal_class.full_signature: @UtilityMethod @Description("Returns the equality of the expected count of messages in accordance with the filter and the actual.<br/>" + "<b>collection</b> - messages for checking.<br/>" + "<b>filter</b> - filter message.<br/>" + "<b>expected</b> - expected number of occurrences of the filter message.<br/>" + "Considering the above said, the final syntax is:<br/>" + "#{getCount(collection, filter, expectedCount)}") public boolean checkCount(Collection<?> collection, Object filter, int expected)
focal_class.identifier: checkCount
focal_class.modifiers: @UtilityMethod @Description("Returns the equality of the expected count of messages in accordance with the filter and the actual.<br/>" + "<b>collection</b> - messages for checking.<br/>" + "<b>filter</b> - filter message.<br/>" + "<b>expected</b> - expected number of occurrences of the filter message.<br/>" + "Considering the above said, the final syntax is:<br/>" + "#{getCount(collection, filter, expectedCount)}") public
focal_class.parameters: (Collection<?> collection, Object filter, int expected)
focal_class.return: boolean
focal_class.signature: boolean checkCount(Collection<?> collection, Object filter, int expected)
focal_class.superclass: extends AbstractCaller
focal_method.body: @UtilityMethod
      @Description("Returns  the equality of the expected count of messages in accordance with the filter and the actual.<br/>"
              + "<b>collection</b> - messages for checking.<br/>"
              + "<b>filter</b> - filter message.<br/>"
              + "<b>expected</b> - expected number of occurrences of the filter message.<br/>"
              + "Considering the above said, the final syntax is:<br/>"
              + "#{getCount(collection, filter, expectedCount)}")
      public boolean checkCount(Collection<?> collection, Object filter, int expected) throws Exception {
          Objects.requireNonNull(collection, "collection cannot be null");
          Objects.requireNonNull(filter, "filter cannot be null");
  
          if (filter instanceof IMessage) {
              IMessage messageFilter = (IMessage)filter;
              int count = 0;
              StringBuilder knownBugBuilder = new StringBuilder();
  
              int itemCount = 0;
              for (Object object : collection) {
                  if (object instanceof IMessage) {
                      ComparatorSettings settings = new ComparatorSettings();
                      IPostValidation validation = new KnownBugPostValidation(null, messageFilter);
                      settings.setPostValidation(validation);
  
                      IMessage message = (IMessage)object;
                      ComparisonResult comparisonResult = MessageComparator.compare(message, messageFilter, settings);
                      StatusType statusType = ComparisonUtil.getStatusType(comparisonResult);
  
                      if (statusType == StatusType.CONDITIONALLY_PASSED || statusType == StatusType.PASSED) {
                          count++;
                          if (statusType == StatusType.CONDITIONALLY_PASSED) {
                              knownBugBuilder.append(itemCount).append(" : ").append(comparisonResult.getExceptionMessage()).append(System.lineSeparator());
                          }
                      }
                  }
                  itemCount++;
              }
  
              if (count == expected) {
                  if (knownBugBuilder.length() != 0) {
                      throw new FieldKnownBugException("Count equlas with known bugs", new BugDescription(knownBugBuilder.toString()));
                  }
                  return true;
              }
              return false;
          } else {
              return Collections.frequency(collection, filter) == expected;
          }
      }
focal_method.class_method_signature: MiscUtils.checkCount(Collection<?> collection, Object filter, int expected)
focal_method.full_signature: @UtilityMethod @Description("Returns the equality of the expected count of messages in accordance with the filter and the actual.<br/>" + "<b>collection</b> - messages for checking.<br/>" + "<b>filter</b> - filter message.<br/>" + "<b>expected</b> - expected number of occurrences of the filter message.<br/>" + "Considering the above said, the final syntax is:<br/>" + "#{getCount(collection, filter, expectedCount)}") public boolean checkCount(Collection<?> collection, Object filter, int expected)
focal_method.identifier: checkCount
focal_method.invocations: requireNonNull requireNonNull setPostValidation compare getStatusType append append append append getExceptionMessage lineSeparator length toString frequency
focal_method.modifiers: @UtilityMethod @Description("Returns the equality of the expected count of messages in accordance with the filter and the actual.<br/>" + "<b>collection</b> - messages for checking.<br/>" + "<b>filter</b> - filter message.<br/>" + "<b>expected</b> - expected number of occurrences of the filter message.<br/>" + "Considering the above said, the final syntax is:<br/>" + "#{getCount(collection, filter, expectedCount)}") public
focal_method.parameters: (Collection<?> collection, Object filter, int expected)
focal_method.return: boolean
focal_method.signature: boolean checkCount(Collection<?> collection, Object filter, int expected)