Class AbstractZipSubject<S extends com.google.common.truth.Subject<S,​T>,​T extends Zip>

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    ZipFileSubject

    public abstract class AbstractZipSubject<S extends com.google.common.truth.Subject<S,​T>,​T extends Zip>
    extends com.google.common.truth.Subject<S,​T>
    implements java.io.Closeable
    Truth support for zip files.
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.google.common.truth.Subject

        com.google.common.truth.Subject.Factory<SubjectT extends com.google.common.truth.Subject<SubjectT,​ActualT>,​ActualT extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractZipSubject​(com.google.common.truth.FailureMetadata failureMetadata, T subject)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      abstract void contains​(java.lang.String path)
      Asserts the zip file contains a file with the specified path.
      void containsFileWithContent​(java.lang.String path, byte[] content)
      Asserts the zip file contains a file with the specified byte array content.
      void containsFileWithContent​(java.lang.String path, java.lang.String content)
      Asserts the zip file contains a file with the specified String content.
      void containsFileWithMatch​(java.lang.String path, java.lang.String pattern)  
      void containsFileWithoutContent​(java.lang.String path, java.lang.String sub)
      Asserts the zip file contains a file without the specified byte sequence anywhere in the file
      abstract void doesNotContain​(java.lang.String path)
      Asserts the zip file does not contains a file with the specified path.
      void doesNotExist()  
      com.google.common.truth.IterableSubject entries​(java.lang.String conformingTo)
      Returns a IterableSubject of all the Zip entries which name matches the passed regular expression.
      void exists()  
      protected byte[] extractContentAsBytes​(java.lang.String path)  
      protected java.lang.String extractContentAsString​(java.lang.String path)  
      • Methods inherited from class com.google.common.truth.Subject

        actual, actualAsString, actualCustomStringRepresentation, check, check, equals, fail, fail, fail, failWithActual, failWithActual, failWithBadResults, failWithCustomSubject, failWithoutActual, failWithoutActual, failWithoutSubject, getSubject, hashCode, ignoreCheck, internalCustomName, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameAs, isNotSameInstanceAs, isNull, isSameAs, isSameInstanceAs, named, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • AbstractZipSubject

        public AbstractZipSubject​(@NonNull
                                  com.google.common.truth.FailureMetadata failureMetadata,
                                  @NonNull
                                  T subject)
    • Method Detail

      • contains

        public abstract void contains​(@NonNull
                                      java.lang.String path)
                               throws java.io.IOException
        Asserts the zip file contains a file with the specified path.
        Throws:
        java.io.IOException
      • doesNotContain

        public abstract void doesNotContain​(@NonNull
                                            java.lang.String path)
                                     throws java.io.IOException
        Asserts the zip file does not contains a file with the specified path.
        Throws:
        java.io.IOException
      • entries

        public final com.google.common.truth.IterableSubject entries​(@NonNull
                                                                     java.lang.String conformingTo)
        Returns a IterableSubject of all the Zip entries which name matches the passed regular expression.
        Parameters:
        conformingTo - a regular expression to match entries we are interested in.
        Returns:
        a IterableSubject propositions for matching entries.
      • containsFileWithContent

        public final void containsFileWithContent​(@NonNull
                                                  java.lang.String path,
                                                  @NonNull
                                                  java.lang.String content)
        Asserts the zip file contains a file with the specified String content.

        Content is trimmed when compared.

      • containsFileWithMatch

        public final void containsFileWithMatch​(@NonNull
                                                java.lang.String path,
                                                @NonNull
                                                java.lang.String pattern)
      • containsFileWithContent

        public final void containsFileWithContent​(@NonNull
                                                  java.lang.String path,
                                                  @NonNull
                                                  byte[] content)
        Asserts the zip file contains a file with the specified byte array content.
      • containsFileWithoutContent

        public final void containsFileWithoutContent​(@NonNull
                                                     java.lang.String path,
                                                     @NonNull
                                                     java.lang.String sub)
        Asserts the zip file contains a file without the specified byte sequence anywhere in the file
      • exists

        public final void exists()
      • doesNotExist

        public final void doesNotExist()
      • close

        public final void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
      • extractContentAsString

        protected final java.lang.String extractContentAsString​(@NonNull
                                                                java.lang.String path)
      • extractContentAsBytes

        @Nullable
        protected final byte[] extractContentAsBytes​(@NonNull
                                                     java.lang.String path)