/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
"scope is not defined"));
}
- String stringCheckResult = Assertions.getStringParameterValidationMessage(SCOPE_STRING, scope, SCOPE_REGEXP);
+ var stringCheckResult = Assertions.getStringParameterValidationMessage(SCOPE_STRING, scope, SCOPE_REGEXP);
if (stringCheckResult != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
"scope invalid-" + stringCheckResult));
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("key=");
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + scope.hashCode();
result = prime * result + (isWritable ? HASH_PRIME_0 : HASH_PRIME_1);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append(this.getClass().getSimpleName());
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + albums.hashCode();
return result;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append(super.toString());
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + super.hashCode();
result = prime * result + schemas.hashCode();
result = prime * result + albums.hashCode();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
"schema flavour is not defined"));
}
- String flavourValidationResult = Assertions.getStringParameterValidationMessage(SCHEMA_FLAVOUR, schemaFlavour,
+ var flavourValidationResult = Assertions.getStringParameterValidationMessage(SCHEMA_FLAVOUR, schemaFlavour,
SCHEMA_FLAVOUR_REGEXP);
if (flavourValidationResult != null) {
result.addValidationMessage(new AxValidationMessage(key, this.getClass(), ValidationResult.INVALID,
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("key=");
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + schemaFlavour.hashCode();
result = prime * result + schemaDefinition.hashCode();
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
@Override
public String toString() {
- final StringBuilder builder = new StringBuilder();
+ final var builder = new StringBuilder();
builder.append(this.getClass().getSimpleName());
builder.append(":(");
builder.append("key=");
*/
@Override
public int hashCode() {
- final int prime = 31;
- int result = 1;
+ final var prime = 31;
+ var result = 1;
result = prime * result + key.hashCode();
result = prime * result + schemas.hashCode();
return result;
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public class ContextAlbumsTest {
@Test
- public void testContextAlbums() {
+ public void testNewAxContectAlbum() {
assertNotNull(new AxContextAlbum());
assertNotNull(new AxContextAlbum(new AxArtifactKey()));
assertNotNull(new AxContextAlbum(new AxArtifactKey(), "AlbumScope", false, new AxArtifactKey()));
+ }
+ @Test
+ public void testContextAlbums() {
final AxArtifactKey albumKey = new AxArtifactKey("AlbumName", "0.0.1");
final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
album.setItemSchema(newSchemaKey);
assertEquals("NewAlbumSchemaName:0.0.1", album.getItemSchema().getId());
album.setItemSchema(albumSchemaKey);
+ }
+
+ private AxContextAlbum setTestAlbum() {
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
+ final AxArtifactKey newSchemaKey = new AxArtifactKey("NewAlbumSchemaName", "0.0.1");
+
+ final AxContextAlbum album = new AxContextAlbum(newKey, "AlbumScope", false, newSchemaKey);
+ album.setScope("NewAlbumScope");
+ album.setWritable(true);
+
+ return album;
+ }
+
+ @Test
+ public void testAxvalidationAlbum() {
+ final AxContextAlbum album = setTestAlbum();
AxValidationResult result = new AxValidationResult();
result = album.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
result = album.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
album.setKey(newKey);
result = new AxValidationResult();
result = album.validate(result);
result = album.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
album.setItemSchema(albumSchemaKey);
result = new AxValidationResult();
result = album.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
- album.clean();
+ }
+
+ @Test
+ public void testEqualsAlbum() {
+ final AxContextAlbum album = setTestAlbum();
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
+ final AxArtifactKey albumSchemaKey = new AxArtifactKey("AlbumSchemaName", "0.0.1");
+ album.setItemSchema(albumSchemaKey);
final AxContextAlbum clonedAlbum = new AxContextAlbum(album);
assertEquals("AxContextAlbum:(key=AxArtifactKey:(name=NewAlbumName,version=0.0.1),"
assertNotEquals(0,
album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, AxArtifactKey.getNullKey())));
assertEquals(0, album.compareTo(new AxContextAlbum(newKey, "NewAlbumScope", true, albumSchemaKey)));
+ }
+ @Test
+ public void testMultipleAlbums() {
final AxContextAlbums albums = new AxContextAlbums();
- result = new AxValidationResult();
+ final AxContextAlbum album = setTestAlbum();
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
+ AxValidationResult result = new AxValidationResult();
result = albums.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
result = albums.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ }
+
+ @Test
+ public void testClonedAlbums() {
+ final AxContextAlbums albums = new AxContextAlbums();
+ final AxContextAlbum album = setTestAlbum();
+ final AxArtifactKey newKey = new AxArtifactKey("NewAlbumName", "0.0.1");
+ albums.setKey(new AxArtifactKey("AlbumsKey", "0.0.1"));
+ albums.getAlbumsMap().put(newKey, album);
albums.clean();
final AxContextAlbums clonedAlbums = new AxContextAlbums(albums);
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2020-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public class ContextSchemasTest {
@Test
- public void testContextSchemas() {
+ public void testNewAxContextSchema() {
assertNotNull(new AxContextSchema());
assertNotNull(new AxContextSchema(new AxArtifactKey(), "SchemaFlavour", "SchemaDefinition"));
+ }
+
+ @Test
+ public void testContextSchemas() {
final AxContextSchema schema = new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour",
"SchemaDefinition");
assertNotNull(schema);
schema.setSchema("NewSchemaDefinition");
assertEquals("NewSchemaDefinition", schema.getSchema());
+ }
+
+ private AxContextSchema setTestSchema() {
+ final AxContextSchema schema = new AxContextSchema(new AxArtifactKey("SchemaName", "0.0.1"), "SchemaFlavour",
+ "SchemaDefinition");
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
+ schema.setKey(newKey);
+ schema.setSchemaFlavour("NewSchemaFlavour");
+ schema.setSchema("NewSchemaDefinition");
+ return schema;
+ }
+
+ @Test
+ public void testAxvalidationSchema() {
+ AxContextSchema schema = setTestSchema();
AxValidationResult result = new AxValidationResult();
result = schema.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
result = schema.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
schema.setKey(newKey);
result = new AxValidationResult();
result = schema.validate(result);
result = new AxValidationResult();
result = schema.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ }
+ @Test
+ public void testEqualsSchema() {
+ AxContextSchema schema = setTestSchema();
schema.clean();
final AxContextSchema clonedSchema = new AxContextSchema(schema);
assertNotNull(schema);
assertNotEquals(schema, (Object) "Hello");
assertNotEquals(schema, new AxContextSchema(new AxArtifactKey(), "Flavour", "Def"));
+
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
assertNotEquals(schema, new AxContextSchema(newKey, "Flavour", "Def"));
assertNotEquals(schema, new AxContextSchema(newKey, "NewSchemaFlavour", "Def"));
assertEquals(schema, new AxContextSchema(newKey, "NewSchemaFlavour", "NewSchemaDefinition"));
assertNotEquals(0, schema.compareTo(new AxContextSchema(newKey, "Flavour", "Def")));
assertNotEquals(0, schema.compareTo(new AxContextSchema(newKey, "NewSchemaFlavour", "Def")));
assertEquals(0, schema.compareTo(new AxContextSchema(newKey, "NewSchemaFlavour", "NewSchemaDefinition")));
+ }
+ @Test
+ public void testMultipleSchemas() {
final AxContextSchemas schemas = new AxContextSchemas();
- result = new AxValidationResult();
+ AxValidationResult result = new AxValidationResult();
result = schemas.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
result = schemas.validate(result);
assertEquals(ValidationResult.INVALID, result.getValidationResult());
+ AxContextSchema schema = setTestSchema();
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
schemas.getSchemasMap().put(newKey, schema);
result = new AxValidationResult();
result = schemas.validate(result);
result = schemas.validate(result);
assertEquals(ValidationResult.VALID, result.getValidationResult());
+ }
+
+ @Test
+ public void testClonedSchemas() {
+ final AxContextSchemas schemas = new AxContextSchemas();
+ AxContextSchema schema = setTestSchema();
+ final AxArtifactKey newKey = new AxArtifactKey("NewSchemaName", "0.0.1");
+ schemas.setKey(new AxArtifactKey("SchemasKey", "0.0.1"));
+ schemas.getSchemasMap().put(newKey, schema);
schemas.clean();
final AxContextSchemas clonedSchemas = new AxContextSchemas(schemas);