NpmMetadataUtils { @Nullable public static DateTime lastModified(final NestedAttributesMap packageRoot) { final NestedAttributesMap time = packageRoot.child(TIME); final String modified = time.get(MODIFIED, String.class); if (modified != null) { return NPM_TIMESTAMP_FORMAT.parseDateTime(modified); } return null; } private  NpmMetadataUtils(); @Nonnull static String extractTarballName(final String tarballUrl); @Nullable static String extractTarballName(final NestedAttributesMap packageMetadata); @Nullable static NestedAttributesMap selectVersionByTarballName(
      final NestedAttributesMap packageRoot,
      final String tarballName); static DateTime maintainTime(final NestedAttributesMap packageRoot); @Nullable static DateTime lastModified(final NestedAttributesMap packageRoot); static void rewriteTarballUrl(final String repositoryName, final NestedAttributesMap packageRoot); static String createRepositoryPath(final String name, final String version); static String createTarballName(final String name, final String version); @Nonnull static NestedAttributesMap shrink(final NestedAttributesMap packageRoot); @Nonnull static NestedAttributesMap overlay(final NestedAttributesMap recessive, final NestedAttributesMap dominant); @Nonnull static NestedAttributesMap merge(final String key, final List<NestedAttributesMap> packages); static NestedAttributesMap mergeContents(final List<Content> contents); static NestedAttributesMap parseContent(final Content content); static Map<String, Object> overlay(
      final Map<String, Object> recessive,
      final Map<String, Object> dominant,
      final boolean mergeVersionDocuments); static String getLatestVersionFromPackageRoot(final NestedAttributesMap pkg); static NestedAttributesMap retrievePackageRoot(
      final NpmPackageId packageId,
      final Context context,
      final Repository repository); static List<String> findCachedVersionsRemovedFromRemote(
      final NestedAttributesMap cachedRoot,
      final NestedAttributesMap newPackageRoot,
      final BiFunction<NpmPackageId, String, Boolean> componentExists); static NestedAttributesMap mergePackageRoots(
      final NestedAttributesMap newPackageRoot,
      final NestedAttributesMap existingPackageRoot, final List<String> cachedVersions); static void removeVersionsNotCachedAndNotInNewRoot(final NestedAttributesMap newPackageRoot,
                                                             final NestedAttributesMap existingPackageRoot,
                                                             final List<String> cachedVersions); @VisibleForTesting
  static final DateTimeFormatter NPM_TIMESTAMP_FORMAT; static final String NAME; static final String DIST_TAGS; static final String VERSIONS; static final String VERSION; static final String DEPRECATED; static final String TIME; static final String DIST; static final String TARBALL; static final String META_ID; static final String META_REV; static final String META_UPDATED; }
@Test public void lastModifiedTest() { NestedAttributesMap package1 = new NestedAttributesMap("package1", Maps.newHashMap()); String modifiedTimestamp = "2016-10-17T00:00:00.000Z"; NestedAttributesMap package2 = new NestedAttributesMap("package2", Maps.newHashMap()); package2.child("time").set("modified", modifiedTimestamp); DateTime package1Modified = NpmMetadataUtils.lastModified(package1); DateTime package2Modified = NpmMetadataUtils.lastModified(package2); DateTime expectedPackage2Modified = NpmMetadataUtils.NPM_TIMESTAMP_FORMAT.parseDateTime(modifiedTimestamp); assertThat(package1Modified, nullValue()); assertThat(package2Modified, equalTo(expectedPackage2Modified)); }