public static void setParsedResourceSchemaConditional(ResourceType resourceType, ResourceSchema parsedSchema) { if (hasParsedSchema(resourceType)) { return; } PrismObject<ResourceType> resource = resourceType.asPrismObject(); resource.setUserData(USER_DATA_KEY_PARSED_RESOURCE_SCHEMA, parsedSchema); }
/** * This basically checks if the methods do not die on NPE */ @Test public void test005ParsedSchemaSchemaless() throws Exception { final String TEST_NAME = "test005ParsedSchemaSchemaless"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceTypeSchemaless)); // Also test if the utility method returns the same thing ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceTypeSchemaless, prismContext); display("Parsed resource schema", returnedSchema); assertNull("Unexpected schema after parsing", returnedSchema); }
/** * Make sure that the refined schema haven't destroyed cached resource schema. * Also make sure that the caching in object's user data works well. */ @Test public void test024ParsedSchemaAgain() throws Exception { final String TEST_NAME = "test024ParsedSchemaAgain"; displayTestTitle(TEST_NAME); // GIVEN // THEN // The returned type should have the schema pre-parsed assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType)); // Also test if the utility method returns the same thing ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext); display("Parsed resource schema", returnedSchema); assertSchemaSanity(returnedSchema, resourceType); assertResourceSchemaUnchanged(returnedSchema); assertSteadyResource(); }
/** * This basically checks if the methods do not die on NPE */ @Test public void test105ParsedSchemaStaticSchema() throws Exception { final String TEST_NAME = "test105ParsedSchemaStaticSchema"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); // THEN // The returned type should have the schema pre-parsed assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceStaticSchema.asObjectable())); // Also test if the utility method returns the same thing ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceStaticSchema.asObjectable(), prismContext); display("Parsed resource schema", returnedSchema); assertNotNull("Null resource schema", returnedSchema); assertStaticSchemaSanity(returnedSchema); }
@Test public void test022ParsedSchema() throws Exception { final String TEST_NAME = "test022ParsedSchema"; displayTestTitle(TEST_NAME); // GIVEN // THEN // The returned type should have the schema pre-parsed assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType)); // Also test if the utility method returns the same thing ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext); display("Parsed resource schema", returnedSchema); // Check whether it is reusing the existing schema and not parsing it // all over again // Not equals() but == ... we want to really know if exactly the same // object instance is returned assertTrue("Broken caching", returnedSchema == RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext)); assertSchemaSanity(returnedSchema, resourceType); rememberResourceSchema(returnedSchema); assertSteadyResource(); }
@Test public void test005ParsedSchema() throws Exception { final String TEST_NAME = "test005ParsedSchema"; TestUtil.displayTestTitle(TEST_NAME); // THEN // The returned type should have the schema pre-parsed assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType)); // Also test if the utility method returns the same thing ResourceSchema resourceSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext); display("Parsed resource schema", resourceSchema); assertNotNull("No resource schema", resourceSchema); ObjectClassComplexTypeDefinition accountDef = resourceSchema.findObjectClassDefinition(RESOURCE_CSV_ACCOUNT_OBJECTCLASS); assertNotNull("Account definition is missing", accountDef); assertNotNull("Null identifiers in account", accountDef.getPrimaryIdentifiers()); assertFalse("Empty identifiers in account", accountDef.getPrimaryIdentifiers().isEmpty()); assertNotNull("No naming attribute in account", accountDef.getNamingAttribute()); assertFalse("No nativeObjectClass in account", StringUtils.isEmpty(accountDef.getNativeObjectClass())); assertAccountDefinition(accountDef); ResourceAttributeDefinition<String> icfsNameDef = accountDef.findAttributeDefinition(SchemaConstants.ICFS_NAME); assertNull("ICFS NAME definition sneaked in", icfsNameDef); ResourceAttributeDefinition<String> icfsUidDef = accountDef.findAttributeDefinition(SchemaConstants.ICFS_UID); assertNull("ICFS UID definition sneaked in", icfsUidDef); // Check whether it is reusing the existing schema and not parsing it all over again // Not equals() but == ... we want to really know if exactly the same // object instance is returned assertTrue("Broken caching", resourceSchema == RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext)); }
assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType));
assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType));