Skip to content

Commit

Permalink
Merge branch 'mosip:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanachandran-s authored Nov 27, 2024
2 parents 19feaaf + 2435755 commit c3b5967
Show file tree
Hide file tree
Showing 134 changed files with 7,605 additions and 2,578 deletions.
53 changes: 28 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,56 @@ Admin module contains following services:
Refer to [SQL scripts](db_scripts).

## Build & run (for developers)
The project requires JDK 1.21.
The project requires JDK 21.0.3
and mvn version - 3.9.6
1. Build and install:
```
$ cd kernel
$ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgpg.skip=true
```
### Remove the version-specific suffix (PostgreSQL95Dialect) from the Hibernate dialect configuration
```
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
```
This is for better compatibility with future PostgreSQL versions.
### Configure ANT Path Matcher for Spring Boot 3.x compatibility.
```
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
```
This is to maintain compatibility with existing ANT-style path patterns.
1. Build Docker for a service:
2. Build Docker for a service:
```
$ cd <service folder>
$ docker build -f Dockerfile
```
### Add auth-adapter in a class-path to run a services
## Deployment in K8 cluster with other MOSIP services:
### Pre-requisites
* Set KUBECONFIG variable to point to existing K8 cluster kubeconfig file:
```
export KUBECONFIG=~/.kube/<k8s-cluster.config>
```
### Install
```
$ cd deploy
$ ./install.sh
```
### Delete
```
$ cd deploy
$ ./delete.sh
```
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-auth-adapter</artifactId>
<version>${kernel.auth.adapter.version}</version>
</dependency>
### Restart
```
$ cd deploy
$ ./restart.sh
```
## Configuration
[Configuration-Admin](https://github.com/mosip/mosip-config/blob/develop/admin-default.properties) and
[Configuration-Application](https://github.com/mosip/mosip-config/blob/develop/application-default.properties) defined here.
admin module uses the following configuration files that are accessible in this [repository](https://github.com/mosip/mosip-config/tree/master).
Please refer to the required released tagged version for configuration.
[Configuration-Admin](https://github.com/mosip/mosip-config/blob/master/admin-default.properties) and
[Configuration-Application](https://github.com/mosip/mosip-config/blob/master/application-default.properties) defined here.
## Deploy
To deploy Admin on Kubernetes cluster using Dockers refer to [Sandbox Deployment](https://docs.mosip.io/1.2.0/deployment/sandbox-deployment).
To deploy Admin on Kubernetes cluster using Dockers refer to [Sandbox Deployment](https://docs.mosip.io/1.2.0/deploymentnew/v3-installation).
## Test
Automated functional tests available in [Functional Tests repo](https://github.com/mosip/mosip-functional-tests).
Automated functional tests available in [Functional Tests repo](api-test).
## APIs
API documentation is available [here](https://mosip.github.io/documentation/).
API documentation is available [here](https://mosip.github.io/documentation/1.2.0/1.2.0.html).
## License
This project is licensed under the terms of [Mozilla Public License 2.0](LICENSE).
21 changes: 11 additions & 10 deletions admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
# Admin
Admin module can be accessed only by the privileged group of admin personnel and enables default configurations and seed data to be setup when the MOSIP platform gets initialized.

## Configuration files
admin module uses the following configuration files:
## Configuration
admin module uses the following configuration files that are accessible in this [repository](https://github.com/mosip/mosip-config/tree/master).
Please refer to the required released tagged version for configuration.
```
application-default.properties
admin-default.properties
Expand All @@ -16,29 +17,29 @@ hotlist-default.properties
Refer [Module Configuration](https://docs.mosip.io/1.2.0/modules/module-configuration) for location of these files.

## Databases
Refer to [SQL scripts](db_scripts).
Refer to [SQL scripts](https://github.com/mosip/admin-services/tree/release-1.3.x/db_scripts).

## Build & run (for developers)
The project requires JDK 1.11.
The project requires JDK 21.0.3
and mvn version - 3.9.6
1. Build and install:
```
$ cd kernel
$ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgpg.skip=true
```
1. Build Docker for a service:
2. Build Docker for a service:
```
$ cd <service folder>
$ docker build -f Dockerfile
```
## Deploy
To deploy Commons services on Kubernetes cluster using Dockers refer to [Sandbox Deployment](https://docs.mosip.io/1.2.0/deployment/sandbox-deployment).
To deploy Commons services on Kubernetes cluster using Dockers refer to [Sandbox Deployment](https://docs.mosip.io/1.2.0/deploymentnew/v3-installation).
## Test
Automated functaionl tests available in [Functional Tests repo](https://github.com/mosip/mosip-functional-tests).
Automated functional tests available in [Functional Tests repo](https://github.com/mosip/admin-services/tree/release-1.3.x/api-test).
## APIs
API documentation is available [here](https://mosip.github.io/documentation/).
API documentation is available [here](https://mosip.github.io/documentation/1.2.0).
## License
This project is licensed under the terms of [Mozilla Public License 2.0](LICENSE).
This project is licensed under the terms of [Mozilla Public License 2.0](https://github.com/mosip/admin-services/blob/release-1.3.x/LICENSE).
45 changes: 8 additions & 37 deletions admin/admin-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,22 @@
Admin Service can be accessed only by the privileged group of admin personnel, its used to perform bulk data operation.

## Build & run (for developers)
The project requires JDK 1.21.
The project requires JDK 21.0.3
and mvn version - 3.9.6
1. Build and install:
```
$ cd kernel
$ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgpg.skip=true
```
### Remove the version-specific suffix (PostgreSQL95Dialect) from the Hibernate dialect configuration
```
hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
```
This is for better compatibility with future PostgreSQL versions.
### Configure ANT Path Matcher for Spring Boot 3.x compatibility.
```
spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER
```
This is to maintain compatibility with existing ANT-style path patterns.
### Add auth-adapter with an exclusion of webflux in a class-path to run an admin-service
```
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-auth-adapter</artifactId>
<version>${kernel.auth.adapter.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</exclusion>
</exclusions>
</dependency>
```
## Configuration files
Admin Service uses the following configuration files:
```
application-default.properties
admin-default.properties
```
## Configuration
[Configuration-Admin](https://github.com/mosip/mosip-config/blob/develop/admin-default.properties) and
[Configuration-Application](https://github.com/mosip/mosip-config/blob/develop/application-default.properties) defined here.
Admin Service uses the following configuration files that are accessible in this [repository](https://github.com/mosip/mosip-config/tree/master).
Please refer to the required released tagged version for configuration.
1. [Configuration-Admin](https://github.com/mosip/mosip-config/blob/master/admin-default.properties)
2. [Configuration-Application](https://github.com/mosip/mosip-config/blob/master/application-default.properties)
## APIs
API documentation is available [here](https://mosip.github.io/documentation/1.2.0/admin-service.html).
Refer [Module Configuration](https://docs.mosip.io/1.2.0/modules/module-configuration) for location of these files.
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package io.mosip.admin.bulkdataupload.batch;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.batch.extensions.excel.support.rowset.RowSet;
import org.springframework.beans.NotWritablePropertyException;
import org.springframework.boot.convert.ApplicationConversionService;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebApplicationContext;
import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.validation.BindException;
import org.springframework.validation.DataBinder;
import org.springframework.validation.DefaultBindingErrorProcessor;
import org.springframework.validation.beanvalidation.CustomValidatorBean;

import javax.validation.ConstraintViolationException;
import java.util.HashSet;
import java.util.Properties;

import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@SpringBootTest
@RunWith(MockitoJUnitRunner.class)
public class CustomExcelRowMapperTest {

@Test
public void createBinder_withApplicationConversionService_returnSuccessResponse() {
ApplicationConversionService conversionService = new ApplicationConversionService();
DataBinder actualCreateBinderResult = (new CustomExcelRowMapper<>(conversionService, new CustomValidatorBean()))
.createBinder("Target");

assertNotNull(actualCreateBinderResult);
assertFalse(actualCreateBinderResult.isIgnoreUnknownFields());
assertFalse(actualCreateBinderResult.isIgnoreInvalidFields());
assertTrue(actualCreateBinderResult.isAutoGrowNestedPaths());
assertNull(actualCreateBinderResult.getValidator());
assertEquals("Target", actualCreateBinderResult.getTarget());
assertEquals("target", actualCreateBinderResult.getObjectName());
assertTrue(actualCreateBinderResult.getBindingErrorProcessor() instanceof DefaultBindingErrorProcessor);
assertEquals(256, actualCreateBinderResult.getAutoGrowCollectionLimit());
}

@Test
public void createBinder_withDefaultFormattingConversionService_returnSuccessResponse() {
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService();

DataBinder actualCreateBinderResult = (new CustomExcelRowMapper<>(conversionService, new CustomValidatorBean()))
.createBinder("Target");

assertNotNull(actualCreateBinderResult);
assertFalse(actualCreateBinderResult.isIgnoreUnknownFields());
assertFalse(actualCreateBinderResult.isIgnoreInvalidFields());
assertTrue(actualCreateBinderResult.isAutoGrowNestedPaths());
assertNull(actualCreateBinderResult.getValidator());
assertEquals("Target", actualCreateBinderResult.getTarget());
assertEquals("target", actualCreateBinderResult.getObjectName());
assertTrue(actualCreateBinderResult.getBindingErrorProcessor() instanceof DefaultBindingErrorProcessor);
assertEquals(256, actualCreateBinderResult.getAutoGrowCollectionLimit());
}

@Test
public void customExcelRowMapper_withSetValues_returnSuccessResponse() {
ApplicationConversionService conversionService = new ApplicationConversionService();
CustomExcelRowMapper<Object> actualCustomExcelRowMapper = new CustomExcelRowMapper<>(conversionService,
new CustomValidatorBean());
actualCustomExcelRowMapper.setBeanFactory(new AnnotationConfigReactiveWebApplicationContext());
actualCustomExcelRowMapper.setDistanceLimit(1);
actualCustomExcelRowMapper.setPrototypeBeanName("Name");
actualCustomExcelRowMapper.setStrict(true);
actualCustomExcelRowMapper.setTargetType(Object.class);
DataBinder dataBinder = new DataBinder("Target", "Object Name");
actualCustomExcelRowMapper.initBinder(dataBinder);
assertNotNull(dataBinder);
}

@Test
public void customExcelRowMapper_withInitBinder_returnSuccessResponse() {
ApplicationConversionService conversionService = new ApplicationConversionService();
CustomExcelRowMapper<Object> actualCustomExcelRowMapper = new CustomExcelRowMapper<>(conversionService,
new CustomValidatorBean());
DataBinder dataBinder = new DataBinder("Target", "Object Name");
actualCustomExcelRowMapper.initBinder(dataBinder);
assertNotNull(dataBinder);
}

@Test(expected = Exception.class)
public void mapRow_withEmptyRowSet_throwException() throws BindException {
ApplicationConversionService conversionService = new ApplicationConversionService();
CustomExcelRowMapper<Object> customExcelRowMapper = new CustomExcelRowMapper<>(conversionService,
new CustomValidatorBean());
customExcelRowMapper.setTargetType(Object.class);
RowSet rowSet = mock(RowSet.class);
when(rowSet.getProperties()).thenReturn(new Properties());
customExcelRowMapper.mapRow(rowSet);
}

@Test(expected = NotWritablePropertyException.class)
public void mapRow_withProperties_throwNotWritablePropertyException() throws BindException {
ApplicationConversionService conversionService = new ApplicationConversionService();
CustomExcelRowMapper<Object> customExcelRowMapper = new CustomExcelRowMapper<>(conversionService,
new CustomValidatorBean());
customExcelRowMapper.setTargetType(Object.class);

Properties properties = new Properties();
properties.setProperty("key", "value");
RowSet rowSet = mock(RowSet.class);
when(rowSet.getProperties()).thenReturn(properties);
customExcelRowMapper.mapRow(rowSet);
}

@Test(expected = ConstraintViolationException.class)
public void mapRow_withConstraintViolation_throwConstraintViolationException() throws BindException {
ApplicationConversionService conversionService = new ApplicationConversionService();
CustomExcelRowMapper<Object> customExcelRowMapper = new CustomExcelRowMapper<>(conversionService,
new CustomValidatorBean());
customExcelRowMapper.setTargetType(Object.class);
RowSet rowSet = mock(RowSet.class);
when(rowSet.getProperties()).thenThrow(new ConstraintViolationException(new HashSet<>()));
customExcelRowMapper.mapRow(rowSet);

}

}
Loading

0 comments on commit c3b5967

Please sign in to comment.