Search in sources :

Example 1 with TestTypeById

use of model.testtypeid.TestTypeById in project cvs-auto-svc by dvsa.

the class DataMapper method findTestType.

private static TestTypeById findTestType(List<TestTypeById> listTest, String testTypeClassification, String forVehicleType, String forVehicleSize, String forVehicleConfiguration, String forVehicleAxles) {
    Boolean found = false;
    TestTypeById testTypeByIdReturned = new TestTypeById();
    testTypeLoop: for (TestTypeById testTypeById : listTest) {
        if ((testTypeById.getNextTestTypesOrCategories() != null)) {
            testTypeByIdReturned = findTestType(testTypeById.getNextTestTypesOrCategories(), testTypeClassification, forVehicleType, forVehicleSize, forVehicleConfiguration, forVehicleAxles);
            if (testTypeByIdReturned != null && testTypeByIdReturned.getId() != null) {
                return testTypeByIdReturned;
            }
        } else {
            int size = 0;
            for (TestCodes testCodes : testTypeById.getTestCodes()) {
                size++;
                if (testTypeById.getTestTypeClassification().equalsIgnoreCase(testTypeClassification) && testCodes.getForVehicleType().equalsIgnoreCase(forVehicleType) && testCodes.getForVehicleSize().equalsIgnoreCase(forVehicleSize) && testCodes.getForVehicleConfiguration().equalsIgnoreCase(forVehicleConfiguration)) {
                    if (forVehicleAxles != null) {
                        if (testTypeByIdReturned.getDefaultTestCode() == null) {
                            testTypeByIdReturned.setDefaultTestCode(testCodes.getDefaultTestCode());
                            testTypeByIdReturned.setLinkedTestCode(testCodes.getLinkedTestCode());
                        }
                        if (testCodes.getForVehicleAxles().equalsIgnoreCase(forVehicleAxles)) {
                            testTypeByIdReturned.setTestTypeClassification(testTypeClassification);
                            testTypeByIdReturned.setId(testTypeById.getId());
                            testTypeByIdReturned.setDefaultTestCode(testCodes.getDefaultTestCode());
                            testTypeByIdReturned.setLinkedTestCode(testCodes.getLinkedTestCode());
                            found = true;
                        } else if (testTypeById.getTestCodes().size() == size && found == false) {
                            testTypeByIdReturned.setTestTypeClassification(testTypeClassification);
                            testTypeByIdReturned.setId(testTypeById.getId());
                            continue;
                        } else {
                            continue;
                        }
                    } else {
                        testTypeByIdReturned.setTestTypeClassification(testTypeClassification);
                        testTypeByIdReturned.setId(testTypeById.getId());
                        testTypeByIdReturned.setDefaultTestCode(testCodes.getDefaultTestCode());
                        testTypeByIdReturned.setLinkedTestCode(testCodes.getLinkedTestCode());
                        found = true;
                        break;
                    }
                }
            }
        }
        if (found == true) {
            return testTypeByIdReturned;
        }
    }
    return testTypeByIdReturned;
}
Also used : TestTypeById(model.testtypeid.TestTypeById) TestCodes(model.testtypeid.TestCodes)

Example 2 with TestTypeById

use of model.testtypeid.TestTypeById in project cvs-auto-svc by dvsa.

the class DataMapper method getNotExistingTestTypeById.

public static TestTypeById getNotExistingTestTypeById(String testTypeClassification, String forVehicleType, String forVehicleSize, String forVehicleConfiguration, String forVehicleAxles) {
    TestTypeById testTypeByIdReturned = null;
    ClassLoader classLoader = new DataMapper().getClass().getClassLoader();
    try {
        ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        TestTypeById[] node = objectMapper.readValue(readFromInputStream(classLoader.getResourceAsStream("loader/" + BaseData.getDataLocation() + "/test-type-by-id.json")), TestTypeById[].class);
        List<TestTypeById> list = Arrays.asList(node);
        testTypeByIdReturned = findNotExistingTestType(list, testTypeClassification, forVehicleType, forVehicleSize, forVehicleConfiguration, forVehicleAxles);
    } catch (IOException e) {
        throw new AutomationException("Error: " + e.getMessage());
    }
    if (testTypeByIdReturned == null) {
        throw new AutomationException("Error finding test type by id. Check file contents: test-type-by-id.json");
    }
    return testTypeByIdReturned;
}
Also used : TestTypeById(model.testtypeid.TestTypeById) AutomationException(exceptions.AutomationException) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with TestTypeById

use of model.testtypeid.TestTypeById in project cvs-auto-svc by dvsa.

the class DataMapper method findNotExistingTestType.

private static TestTypeById findNotExistingTestType(List<TestTypeById> listTest, String testTypeClassification, String forVehicleType, String forVehicleSize, String forVehicleConfiguration, String forVehicleAxles) {
    Boolean found = false;
    TestTypeById testTypeByIdReturned = new TestTypeById();
    testTypeLoop: for (TestTypeById testTypeById : listTest) {
        if ((testTypeById.getNextTestTypesOrCategories() != null)) {
            testTypeByIdReturned = findNotExistingTestType(testTypeById.getNextTestTypesOrCategories(), testTypeClassification, forVehicleType, forVehicleSize, forVehicleConfiguration, forVehicleAxles);
            if (testTypeByIdReturned != null && testTypeByIdReturned.getId() != null) {
                return testTypeByIdReturned;
            }
        } else {
            int size = 0;
            for (TestCodes testCodes : testTypeById.getTestCodes()) {
                size++;
                if (!(testTypeById.getTestTypeClassification().equalsIgnoreCase(testTypeClassification) && testCodes.getForVehicleType().equalsIgnoreCase(forVehicleType) && testCodes.getForVehicleSize().equalsIgnoreCase(forVehicleSize) && testCodes.getForVehicleConfiguration().equalsIgnoreCase(forVehicleConfiguration))) {
                    if (testTypeById.getTestCodes().size() == size && found == false) {
                        testTypeByIdReturned.setTestTypeClassification(testTypeClassification);
                        testTypeByIdReturned.setId(testTypeById.getId());
                        found = true;
                    }
                }
            }
        }
        if (found == true) {
            return testTypeByIdReturned;
        }
    }
    return testTypeByIdReturned;
}
Also used : TestTypeById(model.testtypeid.TestTypeById) TestCodes(model.testtypeid.TestCodes)

Example 4 with TestTypeById

use of model.testtypeid.TestTypeById in project cvs-auto-svc by dvsa.

the class DataMapper method getTestTypeById.

public static TestTypeById getTestTypeById(String testTypeClassification, String forVehicleType, String forVehicleSize, String forVehicleConfiguration, String forVehicleAxles) {
    TestTypeById testTypeByIdReturned = null;
    ClassLoader classLoader = new DataMapper().getClass().getClassLoader();
    try {
        ObjectMapper objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        TestTypeById[] node = objectMapper.readValue(readFromInputStream(classLoader.getResourceAsStream("loader/" + BaseData.getDataLocation() + "/test-type-by-id.json")), TestTypeById[].class);
        List<TestTypeById> list = Arrays.asList(node);
        testTypeByIdReturned = findTestType(list, testTypeClassification, forVehicleType, forVehicleSize, forVehicleConfiguration, forVehicleAxles);
    } catch (IOException e) {
        throw new AutomationException("Error: " + e.getMessage());
    }
    if (testTypeByIdReturned == null) {
        throw new AutomationException("Error finding test type by id. Check file contents: test-type-by-id.json");
    }
    return testTypeByIdReturned;
}
Also used : TestTypeById(model.testtypeid.TestTypeById) AutomationException(exceptions.AutomationException) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

TestTypeById (model.testtypeid.TestTypeById)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 AutomationException (exceptions.AutomationException)2 IOException (java.io.IOException)2 TestCodes (model.testtypeid.TestCodes)2