Skip to content

Commit

Permalink
Upgrade POM and update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
subham-soni committed Sep 16, 2024
1 parent d7e0515 commit ca32b81
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 32 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [0.0.1-RC3]
- Simplified NamespaceDataSource to use a supplier instead of hierarchy for static and dynamic source
- LeiaBundle: Fixed duplicate instantiation of schema repository
- TimeBasedDataProvider: Fixed the initial delay of executor to prevent multiple invocation of update on startup
- Schema Validator: Removed instance creation of schema class. It's not required for static validations.
- SchemaValidationUtils - Fixed strict type validation

## [0.0.1-RC2]
- Added tests to the core functionality to schemaValidator, refresher, client, core and models
- Fixed the validation bug in SchemaValidationUtils. field.getType().isInstanceOf is a miss, Class.isAssignable is the correct way to check for class assignments.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ And
<dependency>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-bom</artifactId>
<versio>0.0.1-RC2</version>
<versio>0.0.1-RC3</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion leia-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
</parent>

<artifactId>leia-bom</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion leia-client-dropwizard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,26 @@ class NamespaceDataSourceTest {

@Test
void testNamespaceDataSource() {
final var staticSource = new StaticNamespaceDataSource(Set.of("testNamespace"));
Assertions.assertNotNull(staticSource);
Assertions.assertNotNull(staticSource.getNamespaces());
Assertions.assertFalse(staticSource.getNamespaces().isEmpty());
final var supplier = new Supplier<Set<String>>() {

private static final AtomicReference<Boolean> supplierMarker = new AtomicReference<>(false);

@Override
public Set<String> get() {
return supplierMarker.get() ?
Set.of("testNamespace") : Set.of();
Set.of("testNamespace") : Set.of();
}

public void mark() {
supplierMarker.set(true);
}
};
final var suppliedSource = new DynamicNamespaceDataSource(supplier);
final var suppliedSource = new NamespaceDataSource(supplier);
Assertions.assertNotNull(suppliedSource.getNamespaces());
Assertions.assertTrue(suppliedSource.getNamespaces().isEmpty());

supplier.mark();
Assertions.assertNotNull(suppliedSource.getNamespaces());
Assertions.assertFalse(suppliedSource.getNamespaces().isEmpty());


}
}
2 changes: 1 addition & 1 deletion leia-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-dropwizard-es/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-dropwizard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-elastic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-models/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-bom</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-bom</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-refresher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public TimeBasedDataProvider(Supplier<T> configSupplier, T initialDefaultValue,
}

public void start() {
this.executorService.scheduleWithFixedDelay(this.updater, 0L, this.delay, this.timeUnit);
this.executorService.scheduleWithFixedDelay(this.updater, this.delay, this.delay, this.timeUnit);
this.update();
}

public void stop() {
Expand Down
2 changes: 1 addition & 1 deletion leia-repository/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion leia-schema-validator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.grookage.leia</groupId>
<artifactId>leia-parent</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<relativePath>../leia-parent</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.grookage.leia.validator.utils;

import com.google.common.collect.Sets;
import com.grookage.leia.models.attributes.*;
import com.grookage.leia.models.schema.SchemaDetails;
import com.grookage.leia.models.schema.SchemaValidationType;
Expand All @@ -34,19 +35,29 @@ public static boolean valid(final SchemaDetails schemaDetails,
final Class<?> klass) {
final var fields = getAllFields(klass);
final var validationType = schemaDetails.getValidationType();
final var attributedNotListed = fields.stream().filter(each -> !schemaDetails.hasAttribute(each.getName()))
.collect(Collectors.toSet());
if (!attributedNotListed.isEmpty() &&
validationType == SchemaValidationType.STRICT) {
log.error("There seems to be attributes present in the class definition that are not in the schema. " +
"[Validation Failed]. The extra attributes are {}",
attributedNotListed);
return false;
}
if (validationType == SchemaValidationType.STRICT && !strictlyMatching(schemaDetails, fields)) return false;
return schemaDetails.getAttributes().stream().allMatch(each ->
valid(each, fields));
}

private static boolean strictlyMatching(SchemaDetails schemaDetails, List<Field> fields) {
final var fieldNames = fields.stream()
.map(Field::getName)
.map(String::toUpperCase)
.collect(Collectors.toSet());
final var attributesListed = schemaDetails.getAttributes().stream()
.map(SchemaAttribute::getName)
.map(String::toUpperCase)
.collect(Collectors.toSet());
final var mismatchedAttributes = Sets.symmetricDifference(fieldNames, attributesListed);
if (mismatchedAttributes.isEmpty()) {
return true;
}
log.error("There seems to be a mismatch in the attributes present in the class definition and schema. " +
"[Validation Failed]. The attributes are {}", mismatchedAttributes);
return false;
}

private static List<Field> getAllFields(Class<?> type) {
List<Field> fields = new ArrayList<>();
for (Class<?> c = type; c != null; c = c.getSuperclass()) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.grookage.leia</groupId>
<artifactId>leia</artifactId>
<version>0.0.1-RC2</version>
<version>0.0.1-RC3</version>
<packaging>pom</packaging>

<name>Leia</name>
Expand Down

0 comments on commit ca32b81

Please sign in to comment.