Skip to content

Commit

Permalink
Fixed PMD errors.
Browse files Browse the repository at this point in the history
Added convenience method to lookup a party bu UUID.
Disabled long-running test.
  • Loading branch information
david-waltermire committed May 3, 2022
1 parent aa6b72c commit 0e42020
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ public static IDocumentNodeItem resolveProfile(@NotNull IDocumentNodeItem profil
throw new MetapathException(String.format("Unable to resolve profile '%s'", profile.getBaseUri()), ex);
}
IBindingContext bindingContext = OscalBindingContext.instance();
IAssemblyClassBinding catalogClassBinding = (IAssemblyClassBinding)ObjectUtils.notNull(bindingContext.getClassBinding(Catalog.class));

retval = IXdmFactory.INSTANCE.newDocumentNodeItem(new RootAssemblyDefinition(catalogClassBinding), resolvedCatalog, profile.getBaseUri());
IAssemblyClassBinding catalogClassBinding
= (IAssemblyClassBinding) ObjectUtils.notNull(bindingContext.getClassBinding(Catalog.class));

retval = IXdmFactory.INSTANCE.newDocumentNodeItem(new RootAssemblyDefinition(catalogClassBinding),
resolvedCatalog, profile.getBaseUri());
}
return retval;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ public abstract class AbstractBackMatter implements IBackMatter {

@Override
public Resource getResourceByUuid(@NotNull UUID uuid) {
List<Resource> resources = getResources();
List<@NotNull Resource> resources = getResources();

Resource retval = null;
if (resources != null) {
retval = resources.stream().filter(resource -> {
return uuid.equals(resource.getUuid());
}).findFirst().orElse(null);
retval = resources.stream()
.filter(resource -> {
return uuid.equals(resource.getUuid());
}).findFirst()
.orElse(null);
}
return retval;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,31 @@
* PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT
* OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER.
*/

package gov.nist.secauto.oscal.lib.model.metadata;

import gov.nist.secauto.oscal.lib.model.BackMatter.Resource;
import gov.nist.secauto.oscal.lib.model.Party;

import org.jetbrains.annotations.NotNull;

import java.util.List;
import java.util.UUID;

public abstract class AbstractMetadata implements IMetadata {

@Override
public Party getPartyByUuid(@NotNull UUID uuid) {
List<@NotNull Party> parties = getParties();

Party retval = null;
if (parties != null) {
retval = parties.stream()
.filter(party -> {
return uuid.equals(party.getUuid());
}).findFirst()
.orElse(null);
}
return retval;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@
* PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, OR AROSE OUT
* OF THE RESULTS OF, OR USE OF, THE SOFTWARE OR SERVICES PROVIDED HEREUNDER.
*/

package gov.nist.secauto.oscal.lib.model.metadata;

import gov.nist.secauto.oscal.lib.model.Location;
import gov.nist.secauto.oscal.lib.model.Party;
import gov.nist.secauto.oscal.lib.model.Role;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.UUID;

public interface IMetadata {
@Nullable
Party getPartyByUuid(@NotNull UUID uuid);

List<@NotNull Role> getRoles();

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/gov/nist/secauto/oscal/java/TestContent.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

class TestContent {
private static final Logger LOGGER = LogManager.getLogger(TestContent.class);

private enum OperationType {
SERIALIZE,
DESERIALIZE;
Expand Down Expand Up @@ -140,7 +140,6 @@ private static <CLASS> void chainReadWrite(File xmlSource, Class<CLASS> clazz, P
}
}

@Disabled
@Test
public void testReadWriteOscalCatalog(@TempDir Path tempDir) throws IOException, BindingException {

Expand All @@ -156,6 +155,7 @@ public void testReadWriteOscalCatalog(@TempDir Path tempDir) throws IOException,
chainReadWrite(catalogSourceXml, Catalog.class, outPath, 1);
}

@Disabled
@Test
public void testOscalCatalogMetrics(@TempDir Path tempDir) throws IOException, BindingException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;


class ProfileResolutionTests {
private static final String XSLT_PATH = "oscal/src/utils/util/resolver-pipeline/oscal-profile-test-helper.xsl";
private static final String PROFILE_PATH = "oscal/src/specifications/profile-resolution/profile-resolution-examples";
Expand Down

0 comments on commit 0e42020

Please sign in to comment.